[llvm] [InstCombine] fold `(icmp eq/ne (or disjoint x, C0), C1)` -> `(icmp eq/ne x, C0^C1)` (PR #87734)

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 7 09:26:38 PDT 2024


================
@@ -951,3 +951,49 @@ define i1 @icmp_or_xor_with_sub_3_6(i64 %x1, i64 %y1, i64 %x2, i64 %y2, i64 %x3,
   %cmp = icmp eq i64 %or1, 0
   ret i1 %cmp
 }
+
+
+define i1 @or_disjoint_with_constants(i8 %x) {
+; CHECK-LABEL: @or_disjoint_with_constants(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[TMP1:%.*]], 18
----------------
AtariDreams wrote:

I don't know if this is equivalent to

and tmp, -2

this clears the last bit only

which means 18 and 19 will both result in icmp eq i8 being true.

But when the and is eliminated, that doesn't work

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


More information about the llvm-commits mailing list