[llvm] 1aa52d6 - [InstSimplify] add abs test with assume; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 1 04:55:21 PDT 2020


Author: Sanjay Patel
Date: 2020-08-01T07:47:06-04:00
New Revision: 1aa52d67d1c1a8eb174d4a85391a17c5f0731116

URL: https://github.com/llvm/llvm-project/commit/1aa52d67d1c1a8eb174d4a85391a17c5f0731116
DIFF: https://github.com/llvm/llvm-project/commit/1aa52d67d1c1a8eb174d4a85391a17c5f0731116.diff

LOG: [InstSimplify] add abs test with assume; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/call.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/call.ll b/llvm/test/Transforms/InstSimplify/call.ll
index e8c39dbda8f9..e4fcf72327cc 100644
--- a/llvm/test/Transforms/InstSimplify/call.ll
+++ b/llvm/test/Transforms/InstSimplify/call.ll
@@ -51,6 +51,21 @@ define <3 x i82> @select_abs(<3 x i1> %cond) {
   ret <3 x i82> %abs
 }
 
+declare void @llvm.assume(i1)
+
+define i32 @assume_abs(i32 %x) {
+; CHECK-LABEL: @assume_abs(
+; CHECK-NEXT:    [[ASSUME:%.*]] = icmp sge i32 [[X:%.*]], 0
+; CHECK-NEXT:    call void @llvm.assume(i1 [[ASSUME]])
+; CHECK-NEXT:    [[ABS:%.*]] = call i32 @llvm.abs.i32(i32 [[X]], i1 true)
+; CHECK-NEXT:    ret i32 [[ABS]]
+;
+  %assume = icmp sge i32 %x, 0
+  call void @llvm.assume(i1 %assume)
+  %abs = call i32 @llvm.abs.i32(i32 %x, i1 true)
+  ret i32 %abs
+}
+
 declare {i8, i1} @llvm.uadd.with.overflow.i8(i8 %a, i8 %b)
 declare {i8, i1} @llvm.sadd.with.overflow.i8(i8 %a, i8 %b)
 declare {i8, i1} @llvm.usub.with.overflow.i8(i8 %a, i8 %b)
@@ -1092,7 +1107,7 @@ define i32 @call_undef_musttail() {
 
 define float @nobuiltin_fmax() {
 ; CHECK-LABEL: @nobuiltin_fmax(
-; CHECK-NEXT:    [[M:%.*]] = call float @fmaxf(float 0.000000e+00, float 1.000000e+00) #3
+; CHECK-NEXT:    [[M:%.*]] = call float @fmaxf(float 0.000000e+00, float 1.000000e+00) #4
 ; CHECK-NEXT:    [[R:%.*]] = call float @llvm.fabs.f32(float [[M]])
 ; CHECK-NEXT:    ret float [[R]]
 ;


        


More information about the llvm-commits mailing list