From 88bab08a886b46409a97297af3f25e8992b5ca83 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 7 Sep 2019 13:35:54 +0000 Subject: [PATCH] [SimplifyCFG][NFC] Autogenerate two tests llvm-svn: 371310 --- .../test/Transforms/SimplifyCFG/SpeculativeExec.ll | 8 +- llvm/test/Transforms/SimplifyCFG/speculate-math.ll | 107 ++++++++++++++++----- 2 files changed, 89 insertions(+), 26 deletions(-) diff --git a/llvm/test/Transforms/SimplifyCFG/SpeculativeExec.ll b/llvm/test/Transforms/SimplifyCFG/SpeculativeExec.ll index 19a7a7e..e9e1d73 100644 --- a/llvm/test/Transforms/SimplifyCFG/SpeculativeExec.ll +++ b/llvm/test/Transforms/SimplifyCFG/SpeculativeExec.ll @@ -12,10 +12,10 @@ define i32 @test1(i32 %a, i32 %b, i32 %c) nounwind { ; CHECK: bb1: ; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[C:%.*]], 1 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[A:%.*]], 1 -; CHECK-NEXT: [[TMP3_A:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[A]] +; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[TMP2]], i32 [[TMP3]], i32 [[A]] ; CHECK-NEXT: br label [[BB3]] ; CHECK: bb3: -; CHECK-NEXT: [[TMP4:%.*]] = phi i32 [ [[B]], [[ENTRY:%.*]] ], [ [[TMP3_A]], [[BB1]] ] +; CHECK-NEXT: [[TMP4:%.*]] = phi i32 [ [[B]], [[ENTRY:%.*]] ], [ [[SPEC_SELECT]], [[BB1]] ] ; CHECK-NEXT: [[TMP5:%.*]] = sub i32 [[TMP4]], 1 ; CHECK-NEXT: ret i32 [[TMP5]] ; @@ -97,8 +97,8 @@ define i32* @test5(i32 %a, i32 %b, i32 %c, i32* dereferenceable(10) %ptr1, ; CHECK: bb1: ; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[C:%.*]], 1 ; CHECK-NEXT: [[TMP3:%.*]] = load i32*, i32** [[PTR3:%.*]] -; CHECK-NEXT: [[TMP3_PTR2:%.*]] = select i1 [[TMP2]], i32* [[TMP3]], i32* [[PTR2:%.*]] -; CHECK-NEXT: ret i32* [[TMP3_PTR2]] +; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[TMP2]], i32* [[TMP3]], i32* [[PTR2:%.*]] +; CHECK-NEXT: ret i32* [[SPEC_SELECT]] ; CHECK: bb3: ; CHECK-NEXT: ret i32* [[PTR1:%.*]] ; diff --git a/llvm/test/Transforms/SimplifyCFG/speculate-math.ll b/llvm/test/Transforms/SimplifyCFG/speculate-math.ll index 87e0166..9edffaf 100644 --- a/llvm/test/Transforms/SimplifyCFG/speculate-math.ll +++ b/llvm/test/Transforms/SimplifyCFG/speculate-math.ll @@ -1,5 +1,6 @@ -; 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 +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -S -simplifycfg < %s | FileCheck %s --check-prefix=ALL --check-prefix=EXPENSIVE +; RUN: opt -S -simplifycfg -speculate-one-expensive-inst=false < %s | FileCheck %s --check-prefix=ALL --check-prefix=CHEAP declare float @llvm.sqrt.f32(float) nounwind readonly declare float @llvm.fma.f32(float, float, float) nounwind readonly @@ -10,11 +11,25 @@ declare float @llvm.maxnum.f32(float, float) nounwind readonly declare float @llvm.minimum.f32(float, float) nounwind readonly declare float @llvm.maximum.f32(float, float) nounwind readonly -; ALL-LABEL: @fdiv_test( -; EXPENSIVE: select i1 %cmp, double %div, double 0.0 -; CHEAP-NOT: select - define double @fdiv_test(double %a, double %b) { +; EXPENSIVE-LABEL: @fdiv_test( +; EXPENSIVE-NEXT: entry: +; EXPENSIVE-NEXT: [[CMP:%.*]] = fcmp ogt double [[A:%.*]], 0.000000e+00 +; EXPENSIVE-NEXT: [[DIV:%.*]] = fdiv double [[B:%.*]], [[A]] +; EXPENSIVE-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[DIV]], double 0.000000e+00 +; EXPENSIVE-NEXT: ret double [[COND]] +; +; CHEAP-LABEL: @fdiv_test( +; CHEAP-NEXT: entry: +; CHEAP-NEXT: [[CMP:%.*]] = fcmp ogt double [[A:%.*]], 0.000000e+00 +; CHEAP-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[COND_END:%.*]] +; CHEAP: cond.true: +; CHEAP-NEXT: [[DIV:%.*]] = fdiv double [[B:%.*]], [[A]] +; CHEAP-NEXT: br label [[COND_END]] +; CHEAP: cond.end: +; CHEAP-NEXT: [[COND:%.*]] = phi double [ [[DIV]], [[COND_TRUE]] ], [ 0.000000e+00, [[ENTRY:%.*]] ] +; CHEAP-NEXT: ret double [[COND]] +; entry: %cmp = fcmp ogt double %a, 0.0 br i1 %cmp, label %cond.true, label %cond.end @@ -28,9 +43,15 @@ cond.end: ret double %cond } -; ALL-LABEL: @sqrt_test( -; ALL: select define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind { +; ALL-LABEL: @sqrt_test( +; ALL-NEXT: entry: +; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 +; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.sqrt.f32(float [[A]]) #2 +; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 +; ALL-NEXT: ret void +; entry: %cmp.i = fcmp olt float %a, 0.000000e+00 br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i @@ -45,9 +66,15 @@ test_sqrt.exit: ; preds = %cond.else.i, %entry ret void } -; ALL-LABEL: @fabs_test( -; ALL: select define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind { +; ALL-LABEL: @fabs_test( +; ALL-NEXT: entry: +; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 +; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fabs.f32(float [[A]]) #2 +; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 +; ALL-NEXT: ret void +; entry: %cmp.i = fcmp olt float %a, 0.000000e+00 br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i @@ -62,9 +89,15 @@ test_fabs.exit: ; preds = %cond.else.i, %entry ret void } -; ALL-LABEL: @fma_test( -; ALL: select define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind { +; ALL-LABEL: @fma_test( +; ALL-NEXT: entry: +; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 +; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fma.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #2 +; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 +; ALL-NEXT: ret void +; entry: %cmp.i = fcmp olt float %a, 0.000000e+00 br i1 %cmp.i, label %test_fma.exit, label %cond.else.i @@ -79,9 +112,15 @@ test_fma.exit: ; preds = %cond.else.i, %entry ret void } -; ALL-LABEL: @fmuladd_test( -; ALL: select define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind { +; ALL-LABEL: @fmuladd_test( +; ALL-NEXT: entry: +; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 +; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.fmuladd.f32(float [[A]], float [[B:%.*]], float [[C:%.*]]) #2 +; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 +; ALL-NEXT: ret void +; entry: %cmp.i = fcmp olt float %a, 0.000000e+00 br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i @@ -96,9 +135,15 @@ test_fmuladd.exit: ; preds = %cond.else.i, %en ret void } -; ALL-LABEL: @minnum_test( -; ALL: select define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { +; ALL-LABEL: @minnum_test( +; ALL-NEXT: entry: +; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 +; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.minnum.f32(float [[A]], float [[B:%.*]]) #2 +; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 +; ALL-NEXT: ret void +; entry: %cmp.i = fcmp olt float %a, 0.000000e+00 br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i @@ -113,9 +158,15 @@ test_minnum.exit: ; preds = %cond.else.i, %ent ret void } -; ALL-LABEL: @maxnum_test( -; ALL: select define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { +; ALL-LABEL: @maxnum_test( +; ALL-NEXT: entry: +; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 +; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.maxnum.f32(float [[A]], float [[B:%.*]]) #2 +; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 +; ALL-NEXT: ret void +; entry: %cmp.i = fcmp olt float %a, 0.000000e+00 br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i @@ -130,9 +181,15 @@ test_maxnum.exit: ; preds = %cond.else.i, %ent ret void } -; ALL-LABEL: @minimum_test( -; ALL: select define void @minimum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { +; ALL-LABEL: @minimum_test( +; ALL-NEXT: entry: +; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 +; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.minimum.f32(float [[A]], float [[B:%.*]]) #2 +; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 +; ALL-NEXT: ret void +; entry: %cmp.i = fcmp olt float %a, 0.000000e+00 br i1 %cmp.i, label %test_minimum.exit, label %cond.else.i @@ -147,9 +204,15 @@ test_minimum.exit: ; preds = %cond.else.i, %en ret void } -; ALL-LABEL: @maximum_test( -; ALL: select define void @maximum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind { +; ALL-LABEL: @maximum_test( +; ALL-NEXT: entry: +; ALL-NEXT: [[CMP_I:%.*]] = fcmp olt float [[A:%.*]], 0.000000e+00 +; ALL-NEXT: [[TMP0:%.*]] = tail call float @llvm.maximum.f32(float [[A]], float [[B:%.*]]) #2 +; ALL-NEXT: [[COND_I:%.*]] = select i1 [[CMP_I]], float 0x7FF8000000000000, float [[TMP0]] +; ALL-NEXT: store float [[COND_I]], float addrspace(1)* [[OUT:%.*]], align 4 +; ALL-NEXT: ret void +; entry: %cmp.i = fcmp olt float %a, 0.000000e+00 br i1 %cmp.i, label %test_maximum.exit, label %cond.else.i -- 2.7.4