Issue 64322
Summary [x86_64] extractelement v1i1 crashes on icelake-server
Labels
Assignees
Reporter oakrc
    [Demo on Compiler Explorer](https://godbolt.org/z/P4hMGMWrh)

- The bug goes away when `-mcpu=icelake-server` is removed.
- Using a constant v1i1 doesn't crash.

Code:
```llvm
@G = global <1 x i1> <i1 true>
@G.1 = global i1 false

define void @foo(i32 %x) {
  %LGV = load <1 x i1>, ptr @G
  ; This works:
  ;%E = extractelement <1 x i1> <i1 true>, i32 %x
  ; This doesn't:
  %E = extractelement <1 x i1> %LGV, i32 %x
  store i1 %E, ptr @G.1
  ret void
}
```

Crash backtrace:
```
LLVM ERROR: Cannot select: 0x8191910: i8 = truncate 0x81912f0
  0x81912f0: i128 = bitcast 0x81917c0
    0x81917c0: v1i128 = sign_extend 0x8191440
 0x8191440: v1i1,ch = load<(dereferenceable load (s8) from @G)> 0x8115160, 0x8191ad0, undef:i64
        0x8191ad0: i64,ch = load<(load (s64) from got)> 0x8115160, 0x8191a60, undef:i64
          0x8191a60: i64 = X86ISD::WrapperRIP TargetGlobalAddress:i64<ptr @G> 0 [TF=5]
 0x8191590: i64 = TargetGlobalAddress<ptr @G> 0 [TF=5]
          0x81913d0: i64 = undef
        0x81913d0: i64 = undef
In function: foo
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=x86_64 -mcpu=icelake-server <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo'
 #0 0x000000000305a128 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x305a128)
 #1 0x0000000003057cec SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f785178e420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f785125100b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f7851230859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x000000000069de84 llvm::RISCVISAInfo::updateImplication() (.cold) RISCVISAInfo.cpp:0:0
 #6 0x0000000002e42ef4 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e42ef4)
 #7 0x0000000002e48585 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e48585)
 #8 0x000000000196ed1d (anonymous namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
 #9 0x0000000002e40557 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e40557)
#10 0x0000000002e4ce15 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e4ce15)
#11 0x0000000002e4f869 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2e4f869)
#12 0x0000000002e51f36 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x0000000001978741 (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#14 0x0000000002439700 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x000000000291aeb2 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x291aeb2)
#16 0x000000000291b031 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x291b031)
#17 0x000000000291cba0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x291cba0)
#18 0x00000000007673f0 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x00000000006a8b82 main (/opt/compiler-explorer/clang-trunk/bin/llc+0x6a8b82)
#20 0x00007f7851232083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#21 0x000000000075f33e _start (/opt/compiler-explorer/clang-trunk/bin/llc+0x75f33e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to