From: Sanjay Patel Date: Fri, 16 Oct 2015 17:18:07 +0000 (+0000) Subject: move test case to x86 directory because it specifies an x86 target X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=62c113616ec77ceb2dca654d4a1cc288e1bb04fb;p=oota-llvm.git move test case to x86 directory because it specifies an x86 target git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250528 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/CodeGenPrepare/X86/select.ll b/test/Transforms/CodeGenPrepare/X86/select.ll new file mode 100644 index 00000000000..5b1a0bafe06 --- /dev/null +++ b/test/Transforms/CodeGenPrepare/X86/select.ll @@ -0,0 +1,114 @@ +; RUN: opt -codegenprepare -S < %s | FileCheck %s + +target triple = "x86_64-unknown-unknown" + +; Nothing to sink here, but this gets converted to a branch to +; avoid stalling an out-of-order CPU on a predictable branch. + +define i32 @no_sink(double %a, double* %b, i32 %x, i32 %y) { +entry: + %load = load double, double* %b, align 8 + %cmp = fcmp olt double %load, %a + %sel = select i1 %cmp, i32 %x, i32 %y + ret i32 %sel + +; CHECK-LABEL: @no_sink( +; CHECK: %load = load double, double* %b, align 8 +; CHECK: %cmp = fcmp olt double %load, %a +; CHECK: br i1 %cmp, label %select.end, label %select.false +; CHECK: select.false: +; CHECK: br label %select.end +; CHECK: select.end: +; CHECK: %sel = phi i32 [ %x, %entry ], [ %y, %select.false ] +; CHECK: ret i32 %sel +} + + +; An 'fdiv' is expensive, so sink it rather than speculatively execute it. + +define float @fdiv_true_sink(float %a, float %b) { +entry: + %div = fdiv float %a, %b + %cmp = fcmp ogt float %a, 1.0 + %sel = select i1 %cmp, float %div, float 2.0 + ret float %sel + +; CHECK-LABEL: @fdiv_true_sink( +; CHECK: %cmp = fcmp ogt float %a, 1.0 +; CHECK: br i1 %cmp, label %select.true.sink, label %select.end +; CHECK: select.true.sink: +; CHECK: %div = fdiv float %a, %b +; CHECK: br label %select.end +; CHECK: select.end: +; CHECK: %sel = phi float [ %div, %select.true.sink ], [ 2.000000e+00, %entry ] +; CHECK: ret float %sel +} + +define float @fdiv_false_sink(float %a, float %b) { +entry: + %div = fdiv float %a, %b + %cmp = fcmp ogt float %a, 3.0 + %sel = select i1 %cmp, float 4.0, float %div + ret float %sel + +; CHECK-LABEL: @fdiv_false_sink( +; CHECK: %cmp = fcmp ogt float %a, 3.0 +; CHECK: br i1 %cmp, label %select.end, label %select.false.sink +; CHECK: select.false.sink: +; CHECK: %div = fdiv float %a, %b +; CHECK: br label %select.end +; CHECK: select.end: +; CHECK: %sel = phi float [ 4.000000e+00, %entry ], [ %div, %select.false.sink ] +; CHECK: ret float %sel +} + +define float @fdiv_both_sink(float %a, float %b) { +entry: + %div1 = fdiv float %a, %b + %div2 = fdiv float %b, %a + %cmp = fcmp ogt float %a, 5.0 + %sel = select i1 %cmp, float %div1, float %div2 + ret float %sel + +; CHECK-LABEL: @fdiv_both_sink( +; CHECK: %cmp = fcmp ogt float %a, 5.0 +; CHECK: br i1 %cmp, label %select.true.sink, label %select.false.sink +; CHECK: select.true.sink: +; CHECK: %div1 = fdiv float %a, %b +; CHECK: br label %select.end +; CHECK: select.false.sink: +; CHECK: %div2 = fdiv float %b, %a +; CHECK: br label %select.end +; CHECK: select.end: +; CHECK: %sel = phi float [ %div1, %select.true.sink ], [ %div2, %select.false.sink ] +; CHECK: ret float %sel +} + +; An 'fadd' is not too expensive, so it's ok to speculate. + +define float @fadd_no_sink(float %a, float %b) { + %add = fadd float %a, %b + %cmp = fcmp ogt float 6.0, %a + %sel = select i1 %cmp, float %add, float 7.0 + ret float %sel + +; CHECK-LABEL: @fadd_no_sink( +; CHECK: %sel = select i1 %cmp, float %add, float 7.0 +} + +; Possible enhancement: sinkability is only calculated with the direct +; operand of the select, so we don't try to sink this. The fdiv cost is not +; taken into account. + +define float @fdiv_no_sink(float %a, float %b) { +entry: + %div = fdiv float %a, %b + %add = fadd float %div, %b + %cmp = fcmp ogt float %a, 1.0 + %sel = select i1 %cmp, float %add, float 8.0 + ret float %sel + +; CHECK-LABEL: @fdiv_no_sink( +; CHECK: %sel = select i1 %cmp, float %add, float 8.0 +} + diff --git a/test/Transforms/CodeGenPrepare/select.ll b/test/Transforms/CodeGenPrepare/select.ll deleted file mode 100644 index 5b1a0bafe06..00000000000 --- a/test/Transforms/CodeGenPrepare/select.ll +++ /dev/null @@ -1,114 +0,0 @@ -; RUN: opt -codegenprepare -S < %s | FileCheck %s - -target triple = "x86_64-unknown-unknown" - -; Nothing to sink here, but this gets converted to a branch to -; avoid stalling an out-of-order CPU on a predictable branch. - -define i32 @no_sink(double %a, double* %b, i32 %x, i32 %y) { -entry: - %load = load double, double* %b, align 8 - %cmp = fcmp olt double %load, %a - %sel = select i1 %cmp, i32 %x, i32 %y - ret i32 %sel - -; CHECK-LABEL: @no_sink( -; CHECK: %load = load double, double* %b, align 8 -; CHECK: %cmp = fcmp olt double %load, %a -; CHECK: br i1 %cmp, label %select.end, label %select.false -; CHECK: select.false: -; CHECK: br label %select.end -; CHECK: select.end: -; CHECK: %sel = phi i32 [ %x, %entry ], [ %y, %select.false ] -; CHECK: ret i32 %sel -} - - -; An 'fdiv' is expensive, so sink it rather than speculatively execute it. - -define float @fdiv_true_sink(float %a, float %b) { -entry: - %div = fdiv float %a, %b - %cmp = fcmp ogt float %a, 1.0 - %sel = select i1 %cmp, float %div, float 2.0 - ret float %sel - -; CHECK-LABEL: @fdiv_true_sink( -; CHECK: %cmp = fcmp ogt float %a, 1.0 -; CHECK: br i1 %cmp, label %select.true.sink, label %select.end -; CHECK: select.true.sink: -; CHECK: %div = fdiv float %a, %b -; CHECK: br label %select.end -; CHECK: select.end: -; CHECK: %sel = phi float [ %div, %select.true.sink ], [ 2.000000e+00, %entry ] -; CHECK: ret float %sel -} - -define float @fdiv_false_sink(float %a, float %b) { -entry: - %div = fdiv float %a, %b - %cmp = fcmp ogt float %a, 3.0 - %sel = select i1 %cmp, float 4.0, float %div - ret float %sel - -; CHECK-LABEL: @fdiv_false_sink( -; CHECK: %cmp = fcmp ogt float %a, 3.0 -; CHECK: br i1 %cmp, label %select.end, label %select.false.sink -; CHECK: select.false.sink: -; CHECK: %div = fdiv float %a, %b -; CHECK: br label %select.end -; CHECK: select.end: -; CHECK: %sel = phi float [ 4.000000e+00, %entry ], [ %div, %select.false.sink ] -; CHECK: ret float %sel -} - -define float @fdiv_both_sink(float %a, float %b) { -entry: - %div1 = fdiv float %a, %b - %div2 = fdiv float %b, %a - %cmp = fcmp ogt float %a, 5.0 - %sel = select i1 %cmp, float %div1, float %div2 - ret float %sel - -; CHECK-LABEL: @fdiv_both_sink( -; CHECK: %cmp = fcmp ogt float %a, 5.0 -; CHECK: br i1 %cmp, label %select.true.sink, label %select.false.sink -; CHECK: select.true.sink: -; CHECK: %div1 = fdiv float %a, %b -; CHECK: br label %select.end -; CHECK: select.false.sink: -; CHECK: %div2 = fdiv float %b, %a -; CHECK: br label %select.end -; CHECK: select.end: -; CHECK: %sel = phi float [ %div1, %select.true.sink ], [ %div2, %select.false.sink ] -; CHECK: ret float %sel -} - -; An 'fadd' is not too expensive, so it's ok to speculate. - -define float @fadd_no_sink(float %a, float %b) { - %add = fadd float %a, %b - %cmp = fcmp ogt float 6.0, %a - %sel = select i1 %cmp, float %add, float 7.0 - ret float %sel - -; CHECK-LABEL: @fadd_no_sink( -; CHECK: %sel = select i1 %cmp, float %add, float 7.0 -} - -; Possible enhancement: sinkability is only calculated with the direct -; operand of the select, so we don't try to sink this. The fdiv cost is not -; taken into account. - -define float @fdiv_no_sink(float %a, float %b) { -entry: - %div = fdiv float %a, %b - %add = fadd float %div, %b - %cmp = fcmp ogt float %a, 1.0 - %sel = select i1 %cmp, float %add, float 8.0 - ret float %sel - -; CHECK-LABEL: @fdiv_no_sink( -; CHECK: %sel = select i1 %cmp, float %add, float 8.0 -} -