• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -instcombine -S -o - | FileCheck %s
2
3target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
4
5; CHECK-LABEL: define float @func1(
6define float @func1(float %a, float %b, float %c, i1 %cond) {
7entry:
8  br i1 %cond, label %cond.true, label %cond.false
9
10cond.true:
11  %sub0 = fsub fast float %a, %b
12  br label %cond.end
13
14cond.false:
15  %sub1 = fsub fast float %a, %c
16  br label %cond.end
17
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]]
22cond.end:
23  %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
24  ret float %e
25}
26
27; CHECK-LABEL: define float @func2(
28define float @func2(float %a, float %b, float %c, i1 %cond) {
29entry:
30  br i1 %cond, label %cond.true, label %cond.false
31
32cond.true:
33  %sub0 = fsub fast float %a, %b
34  br label %cond.end
35
36cond.false:
37  %sub1 = fsub float %a, %c
38  br label %cond.end
39
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]]
44cond.end:
45  %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
46  ret float %e
47}
48
49; CHECK-LABEL: define float @func3(
50define float @func3(float %a, float %b, float %c, i1 %cond) {
51entry:
52  br i1 %cond, label %cond.true, label %cond.false
53
54cond.true:
55  %sub0 = fsub fast float %a, 2.0
56  br label %cond.end
57
58cond.false:
59  %sub1 = fsub fast float %b, 2.0
60  br label %cond.end
61
62; CHECK-LABEL: cond.end
63; CHECK  [[PHI:%[^ ]*]] = phi float [ %a, %cond.true ], [ %b, %cond.false ]
64; CHECK  fadd fast float %a, [[PHI]]
65cond.end:
66  %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
67  ret float %e
68}
69
70; CHECK-LABEL: define float @func4(
71define float @func4(float %a, float %b, float %c, i1 %cond) {
72entry:
73  br i1 %cond, label %cond.true, label %cond.false
74
75cond.true:
76  %sub0 = fsub fast float %a, 2.0
77  br label %cond.end
78
79cond.false:
80  %sub1 = fsub float %b, 2.0
81  br label %cond.end
82
83; CHECK-LABEL: cond.end
84; CHECK  [[PHI:%[^ ]*]] = phi float [ %a, %cond.true ], [ %b, %cond.false ]
85; CHECK  fadd float %a, [[PHI]]
86cond.end:
87  %e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
88  ret float %e
89}
90