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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 09:17:33 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
----------------
nikic wrote:

Yeah, that's a good idea. If !OneUse we need to bail out on the paths that create two instructions, but can still use the ones that create one or zero instructions.

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


More information about the llvm-commits mailing list