[llvm] 8431dba - [InstCombine] add tests for negate with xor operand; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 12:05:21 PDT 2020


Author: Sanjay Patel
Date: 2020-04-01T15:05:13-04:00
New Revision: 8431dbacd495e51f5bbb46d1af9042520098cd75

URL: https://github.com/llvm/llvm-project/commit/8431dbacd495e51f5bbb46d1af9042520098cd75
DIFF: https://github.com/llvm/llvm-project/commit/8431dbacd495e51f5bbb46d1af9042520098cd75.diff

LOG: [InstCombine] add tests for negate with xor operand; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/sub-of-negatible.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/sub-of-negatible.ll b/llvm/test/Transforms/InstCombine/sub-of-negatible.ll
index 01084312c9f8..2b26b304eb6b 100644
--- a/llvm/test/Transforms/InstCombine/sub-of-negatible.ll
+++ b/llvm/test/Transforms/InstCombine/sub-of-negatible.ll
@@ -159,8 +159,8 @@ define i8 @n8(i8 %x, i1 %y, i8 %z) {
 ; x - (y - z) -> x - y + z -> x + (z - y)
 define i8 @t9(i8 %x, i8 %y) {
 ; CHECK-LABEL: @t9(
-; CHECK-NEXT:    [[T01:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    ret i8 [[T01]]
+; CHECK-NEXT:    [[T0_NEG:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret i8 [[T0_NEG]]
 ;
   %t0 = sub i8 %y, %x
   %t1 = sub i8 0, %t0
@@ -375,3 +375,51 @@ define i8 @n21(i8 %x, i16 %y) {
   %t2 = sub i8 %x, %t1
   ret i8 %t2
 }
+
+define i4 @negate_xor(i4 %x) {
+; CHECK-LABEL: @negate_xor(
+; CHECK-NEXT:    [[O:%.*]] = xor i4 [[X:%.*]], 5
+; CHECK-NEXT:    [[R:%.*]] = sub i4 0, [[O]]
+; CHECK-NEXT:    ret i4 [[R]]
+;
+  %o = xor i4 %x, 5
+  %r = sub i4 0, %o
+  ret i4 %r
+}
+
+define <2 x i4> @negate_xor_vec(<2 x i4> %x) {
+; CHECK-LABEL: @negate_xor_vec(
+; CHECK-NEXT:    [[O:%.*]] = xor <2 x i4> [[X:%.*]], <i4 5, i4 -6>
+; CHECK-NEXT:    [[R:%.*]] = sub <2 x i4> zeroinitializer, [[O]]
+; CHECK-NEXT:    ret <2 x i4> [[R]]
+;
+  %o = xor <2 x i4> %x, <i4 5, i4 10>
+  %r = sub <2 x i4> zeroinitializer, %o
+  ret <2 x i4> %r
+}
+
+define i8 @negate_xor_use(i8 %x) {
+; CHECK-LABEL: @negate_xor_use(
+; CHECK-NEXT:    [[O:%.*]] = xor i8 [[X:%.*]], 5
+; CHECK-NEXT:    call void @use8(i8 [[O]])
+; CHECK-NEXT:    [[R:%.*]] = sub i8 0, [[O]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %o = xor i8 %x, 5
+  call void @use8(i8 %o)
+  %r = sub i8 0, %o
+  ret i8 %r
+}
+
+define i4 @negate_shl_xor(i4 %x, i4 %y) {
+; CHECK-LABEL: @negate_shl_xor(
+; CHECK-NEXT:    [[O:%.*]] = xor i4 [[X:%.*]], 5
+; CHECK-NEXT:    [[S:%.*]] = shl i4 [[O]], [[Y:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = sub i4 0, [[S]]
+; CHECK-NEXT:    ret i4 [[R]]
+;
+  %o = xor i4 %x, 5
+  %s = shl i4 %o, %y
+  %r = sub i4 0, %s
+  ret i4 %r
+}


        


More information about the llvm-commits mailing list