diff options
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG')
| -rw-r--r-- | llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll | 24 | ||||
| -rw-r--r-- | llvm/test/Transforms/SimplifyCFG/speculate-math.ll | 42 |
2 files changed, 43 insertions, 23 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll b/llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll index bee80e6acce..69f6c69059d 100644 --- a/llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll +++ b/llvm/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll @@ -7,7 +7,9 @@ define i64 @test1(i64 %A) { ; ALL-LABEL: @test1( ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 ; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) -; ALL-NEXT: select i1 [[COND]], i64 64, i64 [[CTLZ]] +; LZCNT-NEXT: select i1 [[COND]], i64 64, i64 [[CTLZ]] +; BMI-NOT: select +; GENERIC-NOT: select ; ALL: ret entry: %tobool = icmp eq i64 %A, 0 @@ -26,7 +28,9 @@ define i32 @test2(i32 %A) { ; ALL-LABEL: @test2( ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 ; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) -; ALL-NEXT: select i1 [[COND]], i32 32, i32 [[CTLZ]] +; LZCNT-NEXT: select i1 [[COND]], i32 32, i32 [[CTLZ]] +; BMI-NOT: select +; GENERIC-NOT: select ; ALL: ret entry: %tobool = icmp eq i32 %A, 0 @@ -46,7 +50,9 @@ define signext i16 @test3(i16 signext %A) { ; ALL-LABEL: @test3( ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 ; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) -; ALL-NEXT: select i1 [[COND]], i16 16, i16 [[CTLZ]] +; LZCNT-NEXT: select i1 [[COND]], i16 16, i16 [[CTLZ]] +; BMI-NOT: select +; GENERIC-NOT: select ; ALL: ret entry: %tobool = icmp eq i16 %A, 0 @@ -66,7 +72,9 @@ define i64 @test1b(i64 %A) { ; ALL-LABEL: @test1b( ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 ; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) -; ALL-NEXT: select i1 [[COND]], i64 64, i64 [[CTTZ]] +; BMI-NEXT: select i1 [[COND]], i64 64, i64 [[CTTZ]] +; LZCNT-NOT: select +; GENERIC-NOT: select ; ALL: ret entry: %tobool = icmp eq i64 %A, 0 @@ -86,7 +94,9 @@ define i32 @test2b(i32 %A) { ; ALL-LABEL: @test2b( ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 ; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) -; ALL-NEXT: select i1 [[COND]], i32 32, i32 [[CTTZ]] +; BMI-NEXT: select i1 [[COND]], i32 32, i32 [[CTTZ]] +; LZCNT-NOT: select +; GENERIC-NOT: select ; ALL: ret entry: %tobool = icmp eq i32 %A, 0 @@ -106,7 +116,9 @@ define signext i16 @test3b(i16 signext %A) { ; ALL-LABEL: @test3b( ; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 ; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) -; ALL-NEXT: select i1 [[COND]], i16 16, i16 [[CTTZ]] +; BMI-NEXT: select i1 [[COND]], i16 16, i16 [[CTTZ]] +; LZCNT-NOT: select +; GENERIC-NOT: select ; ALL: ret entry: %tobool = icmp eq i16 %A, 0 diff --git a/llvm/test/Transforms/SimplifyCFG/speculate-math.ll b/llvm/test/Transforms/SimplifyCFG/speculate-math.ll index 5655d5d7882..442e8677e97 100644 --- a/llvm/test/Transforms/SimplifyCFG/speculate-math.ll +++ b/llvm/test/Transforms/SimplifyCFG/speculate-math.ll @@ -1,5 +1,4 @@ -; RUN: opt -S -simplifycfg < %s | FileCheck %s --check-prefix=EXPENSIVE --check-prefix=ALL -; RUN: opt -S -simplifycfg -speculate-one-expensive-inst=false < %s | FileCheck %s --check-prefix=CHEAP --check-prefix=ALL +; RUN: opt -S -simplifycfg -phi-node-folding-threshold=2 < %s | FileCheck %s declare float @llvm.sqrt.f32(float) nounwind readonly declare float @llvm.fma.f32(float, float, float) nounwind readonly @@ -8,10 +7,19 @@ declare float @llvm.fabs.f32(float) nounwind readonly declare float @llvm.minnum.f32(float, float) nounwind readonly declare float @llvm.maxnum.f32(float, float) nounwind readonly -; ALL-LABEL: @fdiv_test( -; EXPENSIVE: select i1 %cmp, double %div, double 0.0 -; CHEAP-NOT: select +; FIXME: This is intended to be a temporary test. As discussed in +; D12882, we actually do want to speculate even expensive operations +; in SimplifyCFG because it can expose more optimizations for other +; passes. Therefore, we either need to adjust SimplifyCFG's +; calculations that use the TTI cost model or use a different cost +; model for deciding which ops should be speculated in SimplifyCFG. +; We should also be using the TTI cost model later - for example in +; CodeGenPrepare - to potentially undo this speculation. +; Do not speculate fdiv by default because it is generally expensive. + +; CHECK-LABEL: @fdiv_test( +; CHECK-NOT: select define double @fdiv_test(double %a, double %b) { entry: %cmp = fcmp ogt double %a, 0.0 @@ -26,8 +34,8 @@ cond.end: ret double %cond } -; ALL-LABEL: @sqrt_test( -; ALL: select +; CHECK-LABEL: @sqrt_test( +; CHECK: select define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind { entry: %cmp.i = fcmp olt float %a, 0.000000e+00 @@ -43,8 +51,8 @@ test_sqrt.exit: ; preds = %cond.else.i, %entry ret void } -; ALL-LABEL: @fabs_test( -; ALL: select +; CHECK-LABEL: @fabs_test( +; CHECK: select define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind { entry: %cmp.i = fcmp olt float %a, 0.000000e+00 @@ -60,8 +68,8 @@ test_fabs.exit: ; preds = %cond.else.i, %entry ret void } -; ALL-LABEL: @fma_test( -; ALL: select +; CHECK-LABEL: @fma_test( +; CHECK: select define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind { entry: %cmp.i = fcmp olt float %a, 0.000000e+00 @@ -77,8 +85,8 @@ test_fma.exit: ; preds = %cond.else.i, %entry ret void } -; ALL-LABEL: @fmuladd_test( -; ALL: select +; CHECK-LABEL: @fmuladd_test( +; CHECK: select define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind { entry: %cmp.i = fcmp olt float %a, 0.000000e+00 @@ -94,8 +102,8 @@ test_fmuladd.exit: ; preds = %cond.else.i, %en ret void } -; ALL-LABEL: @minnum_test( -; ALL: select +; CHECK-LABEL: @minnum_test( +; CHECK: select define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { entry: %cmp.i = fcmp olt float %a, 0.000000e+00 @@ -111,8 +119,8 @@ test_minnum.exit: ; preds = %cond.else.i, %ent ret void } -; ALL-LABEL: @maxnum_test( -; ALL: select +; CHECK-LABEL: @maxnum_test( +; CHECK: select define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { entry: %cmp.i = fcmp olt float %a, 0.000000e+00 |

