1 ; RUN: opt < %s -instcombine -S -o - | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
5 ; CHECK-LABEL: define float @func1(
6 define float @func1(float %a, float %b, float %c, i1 %cond) {
8 br i1 %cond, label %cond.true, label %cond.false
11 %sub0 = fsub fast float %a, %b
15 %sub1 = fsub fast float %a, %c
18 ; The fast-math flags should always be transfered if possible.
19 ; CHECK-LABEL: cond.end
20 ; CHECK [[PHI:%[^ ]*]] = phi float [ %b, %cond.true ], [ %c, %cond.false ]
21 ; CHECK fsub fast float %a, [[PHI]]
23 %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
27 ; CHECK-LABEL: define float @func2(
28 define float @func2(float %a, float %b, float %c, i1 %cond) {
30 br i1 %cond, label %cond.true, label %cond.false
33 %sub0 = fsub fast float %a, %b
37 %sub1 = fsub float %a, %c
40 ; The fast-math flags should always be transfered if possible.
41 ; CHECK-LABEL: cond.end
42 ; CHECK [[PHI:%[^ ]*]] = phi float [ %b, %cond.true ], [ %c, %cond.false ]
43 ; CHECK fsub float %a, [[PHI]]
45 %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
49 ; CHECK-LABEL: define float @func3(
50 define float @func3(float %a, float %b, float %c, i1 %cond) {
52 br i1 %cond, label %cond.true, label %cond.false
55 %sub0 = fsub fast float %a, 2.0
59 %sub1 = fsub fast float %b, 2.0
62 ; CHECK-LABEL: cond.end
63 ; CHECK [[PHI:%[^ ]*]] = phi float [ %a, %cond.true ], [ %b, %cond.false ]
64 ; CHECK fadd fast float %a, [[PHI]]
66 %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
70 ; CHECK-LABEL: define float @func4(
71 define float @func4(float %a, float %b, float %c, i1 %cond) {
73 br i1 %cond, label %cond.true, label %cond.false
76 %sub0 = fsub fast float %a, 2.0
80 %sub1 = fsub float %b, 2.0
83 ; CHECK-LABEL: cond.end
84 ; CHECK [[PHI:%[^ ]*]] = phi float [ %a, %cond.true ], [ %b, %cond.false ]
85 ; CHECK fadd float %a, [[PHI]]
87 %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]