[AMDGPU] The llvm.amdgcn.wave.shuffle produced invalid instructions in simulated w64 mode
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Most likely the generic wave shuffle intrinsic is introducing invalid opcodes when w64 mode is turned on with `-mwavefrontsize64` on w32 native targets like gfx1030. Reproducer https://godbolt.org/z/EW18PTnW9
```llvm
define amdgpu_kernel void @kernel() #0 {
entry:
%0 = tail call i32 @llvm.amdgcn.mbcnt.hi(i32 0, i32 0)
%1 = tail call i32 @llvm.amdgcn.wave.shuffle.i32(i32 %0, i32 %0)
store i32 %1, ptr addrspace(1) null, align 4
ret void
}
; Function Attrs: nocallback nocreateundeforpoison nofree nosync nounwind willreturn memory(none)
declare i32 @llvm.amdgcn.mbcnt.hi(i32, i32) #1
; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)
declare i32 @llvm.amdgcn.wave.shuffle.i32(i32, i32) #2
attributes #0 = { "target-features"="+wavefrontsize64" }
attributes #1 = { nocallback nocreateundeforpoison nofree nosync nounwind willreturn memory(none) }
attributes #2 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
```
```console
$ llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1030
llc: /root/llvm-project/llvm/include/llvm/MC/MCInstrInfo.h:91: const llvm::MCInstrDesc& llvm::MCInstrInfo::get(unsigned int) const: Assertion `Opcode < NumOpcodes && "Invalid opcode!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1030
1. Running pass 'CallGraph Pass Manager' on module ''.
2. Running pass 'Branch relaxation pass' on function '@kernel'
#0 0x00000000044bccb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x44bccb8)
#1 0x00000000044b9ae4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x0000773364842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007733648969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x0000773364842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007733648287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000077336482871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x0000773364839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x000000000102c473 (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x102c473)
#9 0x000000000104ee29 llvm::SIInstrInfo::getInstSizeInBytes(llvm::MachineInstr const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x104ee29)
#10 0x000000000300b70d (anonymous namespace)::BranchRelaxation::computeBlockSize(llvm::MachineBasicBlock const&) const (.isra.0) BranchRelaxation.cpp:0:0
#11 0x000000000300e3a7 (anonymous namespace)::BranchRelaxation::run(llvm::MachineFunction&) BranchRelaxation.cpp:0:0
#12 0x0000000003010977 (anonymous namespace)::BranchRelaxationLegacy::runOnMachineFunction(llvm::MachineFunction&) BranchRelaxation.cpp:0:0
#13 0x0000000003222289 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
```
Contributor guide
Research direction
Run the supplied llc reproducer for gfx1030 with the +wavefrontsize64 target feature, then trace the AMDGPU lowering of llvm.amdgcn.wave.shuffle through the Branch relaxation pass shown in the stack trace. Done means the reproducer no longer reaches an invalid opcode assertion and emits valid instructions for simulated w64 mode on a w32 target.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100