[SROA] Fix PR18615 with some long overdue simplifications to the bounds
[oota-llvm.git] / test / Transforms / SimplifyCFG / speculate-math.ll
1 ; RUN: opt -S -simplifycfg -phi-node-folding-threshold=2 < %s | FileCheck %s
2
3 declare float @llvm.sqrt.f32(float) nounwind readonly
4 declare float @llvm.fma.f32(float, float, float) nounwind readonly
5 declare float @llvm.fmuladd.f32(float, float, float) nounwind readonly
6
7 ; CHECK-LABEL: @sqrt_test(
8 ; CHECK: select
9 define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
10 entry:
11   %cmp.i = fcmp olt float %a, 0.000000e+00
12   br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
13
14 cond.else.i:                                      ; preds = %entry
15   %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone
16   br label %test_sqrt.exit
17
18 test_sqrt.exit:                                   ; preds = %cond.else.i, %entry
19   %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
20   store float %cond.i, float addrspace(1)* %out, align 4
21   ret void
22 }
23
24
25 ; CHECK-LABEL: @fma_test(
26 ; CHECK: select
27 define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
28 entry:
29   %cmp.i = fcmp olt float %a, 0.000000e+00
30   br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
31
32 cond.else.i:                                      ; preds = %entry
33   %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
34   br label %test_fma.exit
35
36 test_fma.exit:                                   ; preds = %cond.else.i, %entry
37   %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
38   store float %cond.i, float addrspace(1)* %out, align 4
39   ret void
40 }
41
42 ; CHECK-LABEL: @fmuladd_test(
43 ; CHECK: select
44 define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
45 entry:
46   %cmp.i = fcmp olt float %a, 0.000000e+00
47   br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
48
49 cond.else.i:                                      ; preds = %entry
50   %0 = tail call float @llvm.fmuladd.f32(float %a, float %b, float %c) nounwind readnone
51   br label %test_fmuladd.exit
52
53 test_fmuladd.exit:                                   ; preds = %cond.else.i, %entry
54   %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
55   store float %cond.i, float addrspace(1)* %out, align 4
56   ret void
57 }
58