Issue |
108728
|
Summary |
[X86][ISel] Assertion `(LZ + TZ) < Known.getBitWidth() && "Illegal shifted mask"' failed.
|
Labels |
backend:X86,
crash-on-valid
|
Assignees |
|
Reporter |
dtcxzyw
|
Reproducer: https://godbolt.org/z/5TGro7zbM
```
; bin/llc test.ll -o -
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define i8 @main(i1 %tobool180.not.i150.i) {
entry:
%spec.select = select i1 %tobool180.not.i150.i, i8 0, i8 1
%conv673.i.1.i = xor i8 %spec.select, -1
%0 = udiv i8 1, %conv673.i.1.i
%1 = tail call i8 @llvm.ctpop.i8(i8 %0)
ret i8 %1
}
```
```
llc: /root/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:31722: llvm::SDValue LowerCTPOP(llvm::SDValue, const llvm::X86Subtarget&, llvm::SelectionDAG&): Assertion `(LZ + TZ) < Known.getBitWidth() && "Illegal shifted mask"' failed.
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-assertions-trunk/bin/llc -o /app/output.s -filetype=obj <source>
1. Running pass 'Function Pass Manager' on module '<source>'.
2. Running pass 'X86 DAG->DAG Instruction Selection' on function '@main'
#0 0x0000000003b243a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3b243a8)
#1 0x0000000003b21aec SignalHandler(int) Signals.cpp:0:0
#2 0x0000793749242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007937492969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x0000793749242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007937492287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000079374922871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x0000793749239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x0000000001f709ff LowerCTPOP(llvm::SDValue, llvm::X86Subtarget const&, llvm::SelectionDAG&) X86ISelLowering.cpp:0:0
#9 0x00000000020a8d11 llvm::X86TargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x20a8d11)
#10 0x00000000037c4a38 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) (.part.0) LegalizeDAG.cpp:0:0
#11 0x00000000037c8113 llvm::SelectionDAG::Legalize() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37c8113)
#12 0x00000000038ddc47 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x38ddc47)
#13 0x00000000038e0e92 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x38e0e92)
#14 0x00000000038e21b0 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x38e21b0)
#15 0x00000000038d2eef llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x38d2eef)
#16 0x0000000002abe549 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#17 0x00000000030b1f20 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x30b1f20)
#18 0x00000000030b22d1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x30b22d1)
#19 0x00000000030b2b87 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x30b2b87)
#20 0x000000000085cb7c compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#21 0x000000000074ad56 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x74ad56)
#22 0x0000793749229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#23 0x0000793749229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#24 0x0000000000853b4e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x853b4e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
```
// Compute the lower/upper bounds of the active bits of the value,
// allowing us to shift the active bits down if necessary to fit into the
// special cases below.
KnownBits Known = DAG.computeKnownBits(Op);
unsigned LZ = Known.countMinLeadingZeros();
unsigned TZ = Known.countMinTrailingZeros();
assert((LZ + TZ) < Known.getBitWidth() && "Illegal shifted mask");
unsigned ActiveBits = Known.getBitWidth() - LZ;
unsigned ShiftedActiveBits = Known.getBitWidth() - (LZ + TZ);
```
`LZ + TZ == 2 * BW` when the operand is known to be zero.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs