[llvm] 93073e5 - [InstCombine] add tests for abs with extra use of operand; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 10 11:58:58 PST 2020


Author: Sanjay Patel
Date: 2020-02-10T14:57:37-05:00
New Revision: 93073e52b10efe9f73105ed90a48e0caad9937f5

URL: https://github.com/llvm/llvm-project/commit/93073e52b10efe9f73105ed90a48e0caad9937f5
DIFF: https://github.com/llvm/llvm-project/commit/93073e52b10efe9f73105ed90a48e0caad9937f5.diff

LOG: [InstCombine] add tests for abs with extra use of operand; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/abs-1.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/abs-1.ll b/llvm/test/Transforms/InstCombine/abs-1.ll
index 2b23953497b0..f0d1fea25570 100644
--- a/llvm/test/Transforms/InstCombine/abs-1.ll
+++ b/llvm/test/Transforms/InstCombine/abs-1.ll
@@ -569,3 +569,62 @@ define i1 @abs_must_be_positive(i32 %x) {
   ret i1 %c2
 }
 
+define i8 @abs_swapped(i8 %a) {
+; CHECK-LABEL: @abs_swapped(
+; CHECK-NEXT:    [[NEG:%.*]] = sub i8 0, [[A:%.*]]
+; CHECK-NEXT:    call void @extra_use(i8 [[NEG]])
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp sgt i8 [[A]], 0
+; CHECK-NEXT:    [[M1:%.*]] = select i1 [[CMP1]], i8 [[A]], i8 [[NEG]]
+; CHECK-NEXT:    ret i8 [[M1]]
+;
+  %neg = sub i8 0, %a
+  call void @extra_use(i8 %neg)
+  %cmp1 = icmp sgt i8 %a, 0
+  %m1 = select i1 %cmp1, i8 %a, i8 %neg
+  ret i8 %m1
+}
+
+define i8 @nabs_swapped(i8 %a) {
+; CHECK-LABEL: @nabs_swapped(
+; CHECK-NEXT:    [[NEG:%.*]] = sub i8 0, [[A:%.*]]
+; CHECK-NEXT:    call void @extra_use(i8 [[NEG]])
+; CHECK-NEXT:    [[CMP2:%.*]] = icmp sgt i8 [[A]], 0
+; CHECK-NEXT:    [[M2:%.*]] = select i1 [[CMP2]], i8 [[NEG]], i8 [[A]]
+; CHECK-NEXT:    ret i8 [[M2]]
+;
+  %neg = sub i8 0, %a
+  call void @extra_use(i8 %neg)
+  %cmp2 = icmp sgt i8 %a, 0
+  %m2 = select i1 %cmp2, i8 %neg, i8 %a
+  ret i8 %m2
+}
+
+define i8 @abs_
diff erent_constants(i8 %a) {
+; CHECK-LABEL: @abs_
diff erent_constants(
+; CHECK-NEXT:    [[NEG:%.*]] = sub i8 0, [[A:%.*]]
+; CHECK-NEXT:    call void @extra_use(i8 [[NEG]])
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp sgt i8 [[A]], -1
+; CHECK-NEXT:    [[M1:%.*]] = select i1 [[CMP1]], i8 [[A]], i8 [[NEG]]
+; CHECK-NEXT:    ret i8 [[M1]]
+;
+  %neg = sub i8 0, %a
+  call void @extra_use(i8 %neg)
+  %cmp1 = icmp sgt i8 %a, -1
+  %m1 = select i1 %cmp1, i8 %a, i8 %neg
+  ret i8 %m1
+}
+
+define i8 @nabs_
diff erent_constants(i8 %a) {
+; CHECK-LABEL: @nabs_
diff erent_constants(
+; CHECK-NEXT:    [[NEG:%.*]] = sub i8 0, [[A:%.*]]
+; CHECK-NEXT:    call void @extra_use(i8 [[NEG]])
+; CHECK-NEXT:    [[CMP2:%.*]] = icmp sgt i8 [[A]], -1
+; CHECK-NEXT:    [[M2:%.*]] = select i1 [[CMP2]], i8 [[NEG]], i8 [[A]]
+; CHECK-NEXT:    ret i8 [[M2]]
+;
+  %neg = sub i8 0, %a
+  call void @extra_use(i8 %neg)
+  %cmp2 = icmp sgt i8 %a, -1
+  %m2 = select i1 %cmp2, i8 %neg, i8 %a
+  ret i8 %m2
+}


        


More information about the llvm-commits mailing list