[llvm] 0a1514d - [InstCombine] add test for 'not' vs 'xor'; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 12:50:44 PDT 2020


Author: Sanjay Patel
Date: 2020-08-12T15:50:33-04:00
New Revision: 0a1514d7ca4f34bc515f1911f1d33cddf4224a98

URL: https://github.com/llvm/llvm-project/commit/0a1514d7ca4f34bc515f1911f1d33cddf4224a98
DIFF: https://github.com/llvm/llvm-project/commit/0a1514d7ca4f34bc515f1911f1d33cddf4224a98.diff

LOG: [InstCombine] add test for 'not' vs 'xor'; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/xor.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/xor.ll b/llvm/test/Transforms/InstCombine/xor.ll
index 363fa8ff8fdb..0d863000944e 100644
--- a/llvm/test/Transforms/InstCombine/xor.ll
+++ b/llvm/test/Transforms/InstCombine/xor.ll
@@ -994,3 +994,19 @@ define i4 @or_or_xor_use2(i4 %x, i4 %y, i4 %z, i4* %p) {
   %r = xor i4 %o1, %o2
   ret i4 %r
 }
+
+; PR32706 - https://bugs.llvm.org/show_bug.cgi?id=32706
+; TODO: Pin an xor constant operand to -1 if possible because 'not' is better for SCEV and codegen.
+
+define i32 @not_is_canonical(i32 %x, i32 %y) {
+; CHECK-LABEL: @not_is_canonical(
+; CHECK-NEXT:    [[SUB:%.*]] = xor i32 [[X:%.*]], 1073741823
+; CHECK-NEXT:    [[ADD:%.*]] = add i32 [[SUB]], [[Y:%.*]]
+; CHECK-NEXT:    [[MUL:%.*]] = shl i32 [[ADD]], 2
+; CHECK-NEXT:    ret i32 [[MUL]]
+;
+  %sub = xor i32 %x, 1073741823
+  %add = add i32 %sub, %y
+  %mul = shl i32 %add, 2
+  ret i32 %mul
+}


        


More information about the llvm-commits mailing list