[llvm] [InstCombine] Fold comparison of adding two z/sext booleans (PR #67895)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 10:31:45 PDT 2023


================
@@ -879,7 +879,8 @@ define i1 @zext_sext_add_icmp_slt_minus_1_no_oneuse(i1 %a, i1 %b) {
 ; CHECK-NEXT:    [[SEXT_B:%.*]] = sext i1 [[B:%.*]] to i8
 ; CHECK-NEXT:    [[ADD:%.*]] = add nsw i8 [[ZEXT_A]], [[SEXT_B]]
 ; CHECK-NEXT:    call void @use(i8 [[ADD]])
-; CHECK-NEXT:    ret i1 false
+; CHECK-NEXT:    [[R:%.*]] = icmp slt i8 [[ADD]], -1
----------------
elhewaty wrote:

```
static llvm::BinaryOperator* llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, const llvm::Twine&, llvm::Instruction*): Assertion `S1->getType() == S2->getType() && "Cannot create binary operator with two operands of differing type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt -passes=instcombine -S
 #0 0x0000558a8819fa60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x2cb2a60)
 #1 0x0000558a8819ce6f llvm::sys::RunSignalHandlers() (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x2cafe6f)
 #2 0x0000558a8819cfc5 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007ff28d842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007ff28d896a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007ff28d896a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007ff28d896a7c pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007ff28d842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007ff28d8287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007ff28d82871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007ff28d839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x0000558a87af08a5 (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x26038a5)
#12 0x0000558a87aff874 (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x2612874)
#13 0x0000558a8732cd00 llvm::IRBuilderBase::CreateOr(llvm::Value*, llvm::Value*, llvm::Twine const&) AtomicExpandPass.cpp:0:0
#14 0x0000558a87d35ebb llvm::InstCombinerImpl::foldICmpAddConstant(llvm::ICmpInst&, llvm::BinaryOperator*, llvm::APInt const&) InstCombineCompares.cpp:0:0
#15 0x0000558a87d4c7a8 llvm::InstCombinerImpl::foldICmpBinOpWithConstant(llvm::ICmpInst&, llvm::BinaryOperator*, llvm::APInt const&) InstCombineCompares.cpp:0:0
#16 0x0000558a87d4ca53 llvm::InstCombinerImpl::foldICmpInstWithConstant(llvm::ICmpInst&) InstCombineCompares.cpp:0:0
#17 0x0000558a87d51c88 llvm::InstCombinerImpl::visitICmpInst(llvm::ICmpInst&) InstCombineCompares.cpp:0:0
#18 0x0000558a87cb725c llvm::InstCombinerImpl::run() InstructionCombining.cpp:0:0
#19 0x0000558a87cb891d combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, unsigned int, bool, llvm::LoopInfo*) InstructionCombining.cpp:0:0
#20 0x0000558a87cb98d1 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x27cc8d1)
#21 0x0000558a883ab0b6 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
#22 0x0000558a87b8a5b1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x269d5b1)
#23 0x0000558a883a3bc6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
#24 0x0000558a87b892ab llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x269c2ab)
#25 0x0000558a883aad46 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilder.cpp:0:0
#26 0x0000558a87b87091 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x269a091)
#27 0x0000558a86b14fb5 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x1627fb5)
#28 0x0000558a86b247b8 main (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x16377b8)
#29 0x00007ff28d829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#30 0x00007ff28d829e40 call_init ./csu/../csu/libc-start.c:128:20
#31 0x00007ff28d829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#32 0x0000558a86b077a5 _start (/media/mohamed/Local-Disk/open-source/New-LLVM/build/bin/opt+0x161a7a5)
Aborted (core dumped)
```

https://github.com/llvm/llvm-project/pull/67895


More information about the llvm-commits mailing list