[llvm] [InstCombine] Fold shift of boolean zext to logic sequence (PR #180596)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 13 05:59:56 PST 2026
================
@@ -499,3 +499,156 @@ entry:
%cmp = icmp eq <2 x i16> %and, zeroinitializer
ret <2 x i1> %cmp
}
+
+; verify icmp(binop(bool_map, bool_map), constant) coverage
+
+define i1 @icmp_ne_add_sext_sext(i1 %a, i1 %b) {
+; CHECK-LABEL: @icmp_ne_add_sext_sext(
+; CHECK-NEXT: ret i1 true
+;
+ %s2 = sext i1 %a to i8
+ %s1 = sext i1 %b to i8
+ %add = add i8 %s1, %s2
+ %cmp = icmp ne i8 %add, 1
+ ret i1 %cmp
+}
+
+
+define i1 @icmp_ult_sub_select_select(i1 %a, i1 %b) {
+; CHECK-LABEL: @icmp_ult_sub_select_select(
+; CHECK-NEXT: [[TMP1:%.*]] = xor i1 [[A:%.*]], true
+; CHECK-NEXT: [[CMP:%.*]] = or i1 [[B:%.*]], [[TMP1]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %s2 = select i1 %a, i8 1, i8 0
----------------
nikic wrote:
For the tests using selects, can you please use values other than 1 and 0? Otherwise this will just fold to a zext.
https://github.com/llvm/llvm-project/pull/180596
More information about the llvm-commits
mailing list