[llvm] 9586656 - [InstCombine] add multi-use tests for negator; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 09:20:27 PST 2020


Author: Sanjay Patel
Date: 2020-11-02T12:20:17-05:00
New Revision: 9586656f4e3cf53a2755ad965773909b52728332

URL: https://github.com/llvm/llvm-project/commit/9586656f4e3cf53a2755ad965773909b52728332
DIFF: https://github.com/llvm/llvm-project/commit/9586656f4e3cf53a2755ad965773909b52728332.diff

LOG: [InstCombine] add multi-use tests for negator; NFC

PR47997

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 3d988c9f3d4a..8f56b48d570f 100644
--- a/llvm/test/Transforms/InstCombine/sub-of-negatible.ll
+++ b/llvm/test/Transforms/InstCombine/sub-of-negatible.ll
@@ -169,6 +169,7 @@ define i8 @t9(i8 %x, i8 %y) {
   %t1 = sub i8 0, %t0
   ret i8 %t1
 }
+
 define i8 @n10(i8 %x, i8 %y, i8 %z) {
 ; CHECK-LABEL: @n10(
 ; CHECK-NEXT:    [[T0:%.*]] = sub i8 [[Y:%.*]], [[X:%.*]]
@@ -182,6 +183,32 @@ define i8 @n10(i8 %x, i8 %y, i8 %z) {
   ret i8 %t1
 }
 
+define i8 @negator_sub_constant_multi_use(i8 %x) {
+; CHECK-LABEL: @negator_sub_constant_multi_use(
+; CHECK-NEXT:    [[S:%.*]] = sub nsw i8 42, [[X:%.*]]
+; CHECK-NEXT:    call void @use8(i8 [[S]])
+; CHECK-NEXT:    [[R:%.*]] = sub nsw i8 0, [[S]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %s = sub nsw i8 42, %x
+  call void @use8(i8 %s)
+  %r = sub nsw i8 0, %s
+  ret i8 %r
+}
+
+define <2 x i8> @negator_sub_constant_multi_use_vec(<2 x i8> %x, <2 x i8>* %p) {
+; CHECK-LABEL: @negator_sub_constant_multi_use_vec(
+; CHECK-NEXT:    [[S:%.*]] = sub nsw <2 x i8> <i8 42, i8 -17>, [[X:%.*]]
+; CHECK-NEXT:    store <2 x i8> [[S]], <2 x i8>* [[P:%.*]], align 2
+; CHECK-NEXT:    [[R:%.*]] = sub nsw <2 x i8> zeroinitializer, [[S]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %s = sub nsw <2 x i8> <i8 42, i8 -17>, %x
+  store <2 x i8> %s, <2 x i8>* %p
+  %r = sub nsw <2 x i8> zeroinitializer, %s
+  ret <2 x i8> %r
+}
+
 ; Addition can be negated if both operands can be negated
 ; x - (y + z) -> x - y - z -> x + ((-y) + (-z)))
 define i8 @t12(i8 %x, i8 %y, i8 %z) {


        


More information about the llvm-commits mailing list