[llvm] 69ec84f - [NFC][InstCombine] Add 'x - (x & y)' tests with multi-use 'and'

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 08:41:32 PST 2020


Author: Roman Lebedev
Date: 2020-03-06T19:41:19+03:00
New Revision: 69ec84f8e7fa7dec4ba1b1d16ffadfa4a18ac635

URL: https://github.com/llvm/llvm-project/commit/69ec84f8e7fa7dec4ba1b1d16ffadfa4a18ac635
DIFF: https://github.com/llvm/llvm-project/commit/69ec84f8e7fa7dec4ba1b1d16ffadfa4a18ac635.diff

LOG: [NFC][InstCombine] Add 'x - (x & y)' tests with multi-use 'and'

If %y is constant, we could still perform the fold

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/sub.ll b/llvm/test/Transforms/InstCombine/sub.ll
index b291fb89a984..1b8ef83f7b63 100644
--- a/llvm/test/Transforms/InstCombine/sub.ll
+++ b/llvm/test/Transforms/InstCombine/sub.ll
@@ -1513,3 +1513,29 @@ define i32 @nsw_inference2(i32 %x, i32 %y) {
   %z = sub i32 %x2, %y2
   ret i32 %z
 }
+
+define i8 @test74(i8 %x, i8 %y) {
+; CHECK-LABEL: @test74(
+; CHECK-NEXT:    [[T0:%.*]] = and i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    call void @use8(i8 [[T0]])
+; CHECK-NEXT:    [[T1:%.*]] = sub i8 [[X]], [[T0]]
+; CHECK-NEXT:    ret i8 [[T1]]
+;
+  %t0 = and i8 %x, %y
+  call void @use8(i8 %t0)
+  %t1 = sub i8 %x, %t0
+  ret i8 %t1
+}
+
+define i8 @test75(i8 %x) {
+; CHECK-LABEL: @test75(
+; CHECK-NEXT:    [[T0:%.*]] = and i8 [[X:%.*]], -8
+; CHECK-NEXT:    call void @use8(i8 [[T0]])
+; CHECK-NEXT:    [[T1:%.*]] = sub i8 [[X]], [[T0]]
+; CHECK-NEXT:    ret i8 [[T1]]
+;
+  %t0 = and i8 %x, -8
+  call void @use8(i8 %t0)
+  %t1 = sub i8 %x, %t0
+  ret i8 %t1
+}


        


More information about the llvm-commits mailing list