[llvm] [InstCombine] Simplify a complex OR to XOR (PR #75129)

Fujun Han via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 22:47:38 PST 2023


================
@@ -0,0 +1,36 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+; Pattern:
+;   (or (and (add x, half_c1), c3), (and x, c2))
+; IFF:
+;   c1, c2, c3 is constant
+;   c1 is pow2
+;   c2 < c1
+;   c3 == (c1 - 1) ^ c2
+;   half_c1 == (lshr c1, 1)
+;   (c1 >> 1) & c3 == (c1 >> 1)
+;   x is known to be less than c1
+; Could be transformed into:
+;   (xor x, half_c1)
+; Proof: https://alive2.llvm.org/ce/z/Lfax3w
+
+define i16 @or_and_add_and() {
----------------
Peter9606 wrote:

done!

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


More information about the llvm-commits mailing list