[llvm] [InstCombine] Fold `icmp eq/ne (X and C), 0` when partial bits are known (PR #85863)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 19 14:16:58 PDT 2024
================
@@ -403,3 +403,88 @@ truelabel:
falselabel:
ret i8 0
}
+
+define i1 @and_mask1_eq(i32 %conv) {
+; CHECK-LABEL: @and_mask1_eq(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[CONV:%.*]], 1
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[AND]], 0
+; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: ret i1 false
+; CHECK: else:
+; CHECK-NEXT: call void @dummy()
+; CHECK-NEXT: ret i1 false
+;
+entry:
+ %and = and i32 %conv, 1
+ %cmp = icmp eq i32 %and, 0
+ br i1 %cmp, label %then, label %else
+
+then:
+ ret i1 0
+
+else:
+ call void @dummy()
----------------
nikic wrote:
Drop the dummy calls -- they're not needed for InstCombine-only tests.
https://github.com/llvm/llvm-project/pull/85863
More information about the llvm-commits
mailing list