Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: ICX Assembly comments for AVX2 Intrinsics are missing when using cmake #6550

Open
petrock99 opened this issue Jun 2, 2024 · 5 comments
Labels
probably-wont-happen PRs are welcomed, but we do not currently plan on implementing this request Request for something

Comments

@petrock99
Copy link

Describe the bug

If I set up source editor to use icx-2023.1.0 with some C code that uses AVX2 Intrinsics there will be comments next to some of the corresponding assembly instructions. i.e. # AlignMOV convert to UnAlignMOV, # ymm0 = (ymm1 * ymm0) + mem or the ever important # 32-byte Spill.

But if I build the same exact code with cmake these comments are missing. Maybe I'm missing a flag in the CMakeLists.txt to enable this feature in Compiler Explorer?

Steps to reproduce

Expected behavior

Both compiler sections should show identical content, including the assembly comments.

square:
  vmovupd ymm1, ymmword ptr [rdi] # AlignMOV convert to UnAlignMOV
  vmovupd ymm0, ymmword ptr [rdi + 8] # AlignMOV convert to UnAlignMOV
  vfmadd213pd ymm0, ymm1, ymmword ptr [rdi + 16] # ymm0 = (ymm1 * ymm0) + mem

Reproduction link

https://godbolt.org/z/v7zqfv9vd

Screenshots

Screenshot 2024-06-01 at 8 38 59 PM

Operating System

macOS 14.5

Browser version

Safari 17.5

@petrock99 petrock99 added the bug label Jun 2, 2024
@petrock99
Copy link
Author

petrock99 commented Jun 2, 2024

When I click the Green Checkmark to see the compilation options used the compiler on the left shows:
-gdwarf-4 -g -o output.s -masm=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-13.1.0 -fcolor-diagnostics -fno-crash-diagnostics -std=c11 -O3 -g -march=alderlake -mtune=alderlake example.c

and the compiler on the right shows:
-fcolor-diagnostics -fno-crash-diagnostics

Sadly, if I add -gdwarf-4, -masm=intel and --gcc-toolchain=/opt/compiler-explorer/gcc-13.1.0 to the add_compile_options section in the CMakeLists.txt the problem still reproduces.

Another thing that is interesting is the compiler section on the left has slightly different assembly for the vfmadd213pd instruction:
left: [rdi + 16]
right: [rdi+0x10]

It's decimal vs hex. I'm not sure if that is related to this bug or not, or if I somehow enabled some formatting feature.

@partouf
Copy link
Contributor

partouf commented Jun 5, 2024

ASM shown when using CMake, is equivalent to using 'Link to binary' when compiling a file directly. (It is compiled and then the executable is disassembled with objdump)

There is no equivalent to -S when using CMake and this is also not possible to implement, sorry.

@partouf partouf added wont-fix Not in our interest or ability to fix this/Not a bug and removed bug labels Jun 5, 2024
@partouf partouf closed this as completed Jun 5, 2024
@petrock99
Copy link
Author

Sure you can.

  • To build without linking, substitute add_library for add_executable in the CMakeLists.txt file. Since the CMakeLists.txt is on your servers, you can parse & modify them on the fly, right? cmake also supports nested CMakeLists.txt files. So you could nest the users CMakeLists.txt into your own CMakeLists.txt and copy/modify the state how you like. I haven't tried that, but in theory it could work.

  • To get .s files use -save-temps instead of -S. Works like a charm with icx, gcc & clang. I'm not sure about other compilers. I've attached a sample project to demonstrate this working.

unzip TestCMakeASM.zip
cd TestCMakeASM
cmake . -DCMAKE_C_COMPILER=icx -DCMAKE_BUILD_TYPE=Release
make
less test.s

Hope that helps.

Should I file a new bug or can this one be re-opened? Thanks.

TestCMakeASM.zip

@partouf partouf reopened this Jun 6, 2024
@partouf
Copy link
Contributor

partouf commented Jun 6, 2024

You're free to send a PR

@petrock99
Copy link
Author

Sadly, due to my job I'm not allowed to contribute to open source projects. I wish I could.

Could the 'wont-fix' flag be removed? Thanks.

@partouf partouf added request Request for something probably-wont-happen PRs are welcomed, but we do not currently plan on implementing this and removed wont-fix Not in our interest or ability to fix this/Not a bug labels Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
probably-wont-happen PRs are welcomed, but we do not currently plan on implementing this request Request for something
Projects
None yet
Development

No branches or pull requests

2 participants