1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S -o - | FileCheck %s
4 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
6 define float @func1(float %a, float %b, float %c, i1 %cond) {
9 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
11 ; CHECK-NEXT: br label [[COND_END:%.*]]
13 ; CHECK-NEXT: br label [[COND_END]]
15 ; CHECK-NEXT: [[B_PN:%.*]] = phi float [ [[B:%.*]], [[COND_TRUE]] ], [ [[C:%.*]], [[COND_FALSE]] ]
16 ; CHECK-NEXT: [[E:%.*]] = fsub fast float [[A:%.*]], [[B_PN]]
17 ; CHECK-NEXT: ret float [[E]]
20 br i1 %cond, label %cond.true, label %cond.false
23 %sub0 = fsub fast float %a, %b
27 %sub1 = fsub fast float %a, %c
30 ; The fast-math flags should always be transfered if possible.
32 %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
36 define float @func2(float %a, float %b, float %c, i1 %cond) {
37 ; CHECK-LABEL: @func2(
39 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
41 ; CHECK-NEXT: br label [[COND_END:%.*]]
43 ; CHECK-NEXT: br label [[COND_END]]
45 ; CHECK-NEXT: [[B_PN:%.*]] = phi float [ [[B:%.*]], [[COND_TRUE]] ], [ [[C:%.*]], [[COND_FALSE]] ]
46 ; CHECK-NEXT: [[E:%.*]] = fsub float [[A:%.*]], [[B_PN]]
47 ; CHECK-NEXT: ret float [[E]]
50 br i1 %cond, label %cond.true, label %cond.false
53 %sub0 = fsub fast float %a, %b
57 %sub1 = fsub float %a, %c
60 ; The fast-math flags should always be transfered if possible.
62 %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
66 define float @func3(float %a, float %b, float %c, i1 %cond) {
67 ; CHECK-LABEL: @func3(
69 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
71 ; CHECK-NEXT: br label [[COND_END:%.*]]
73 ; CHECK-NEXT: br label [[COND_END]]
75 ; CHECK-NEXT: [[E_IN:%.*]] = phi float [ [[A:%.*]], [[COND_TRUE]] ], [ [[B:%.*]], [[COND_FALSE]] ]
76 ; CHECK-NEXT: [[E:%.*]] = fadd fast float [[E_IN]], -2.000000e+00
77 ; CHECK-NEXT: ret float [[E]]
80 br i1 %cond, label %cond.true, label %cond.false
83 %sub0 = fsub fast float %a, 2.0
87 %sub1 = fsub fast float %b, 2.0
91 %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
95 define float @func4(float %a, float %b, float %c, i1 %cond) {
96 ; CHECK-LABEL: @func4(
98 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
100 ; CHECK-NEXT: br label [[COND_END:%.*]]
102 ; CHECK-NEXT: br label [[COND_END]]
104 ; CHECK-NEXT: [[E_IN:%.*]] = phi float [ [[A:%.*]], [[COND_TRUE]] ], [ [[B:%.*]], [[COND_FALSE]] ]
105 ; CHECK-NEXT: [[E:%.*]] = fadd float [[E_IN]], -2.000000e+00
106 ; CHECK-NEXT: ret float [[E]]
109 br i1 %cond, label %cond.true, label %cond.false
112 %sub0 = fsub fast float %a, 2.0
116 %sub1 = fsub float %b, 2.0
120 %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]