phi-preserve-ir-flags.ll
3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S -o - | FileCheck %s
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
define float @func1(float %a, float %b, float %c, i1 %cond) {
; CHECK-LABEL: @func1(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[COND:%.*]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
; CHECK: cond.true:
; CHECK-NEXT: br label [[COND_END:%.*]]
; CHECK: cond.false:
; CHECK-NEXT: br label [[COND_END]]
; CHECK: cond.end:
; CHECK-NEXT: [[B_PN:%.*]] = phi float [ [[B:%.*]], [[COND_TRUE]] ], [ [[C:%.*]], [[COND_FALSE]] ]
; CHECK-NEXT: [[E:%.*]] = fsub fast float [[A:%.*]], [[B_PN]]
; CHECK-NEXT: ret float [[E]]
;
entry:
br i1 %cond, label %cond.true, label %cond.false
cond.true:
%sub0 = fsub fast float %a, %b
br label %cond.end
cond.false:
%sub1 = fsub fast float %a, %c
br label %cond.end
; The fast-math flags should always be transfered if possible.
cond.end:
%e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
ret float %e
}
define float @func2(float %a, float %b, float %c, i1 %cond) {
; CHECK-LABEL: @func2(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[COND:%.*]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
; CHECK: cond.true:
; CHECK-NEXT: br label [[COND_END:%.*]]
; CHECK: cond.false:
; CHECK-NEXT: br label [[COND_END]]
; CHECK: cond.end:
; CHECK-NEXT: [[B_PN:%.*]] = phi float [ [[B:%.*]], [[COND_TRUE]] ], [ [[C:%.*]], [[COND_FALSE]] ]
; CHECK-NEXT: [[E:%.*]] = fsub float [[A:%.*]], [[B_PN]]
; CHECK-NEXT: ret float [[E]]
;
entry:
br i1 %cond, label %cond.true, label %cond.false
cond.true:
%sub0 = fsub fast float %a, %b
br label %cond.end
cond.false:
%sub1 = fsub float %a, %c
br label %cond.end
; The fast-math flags should always be transfered if possible.
cond.end:
%e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
ret float %e
}
define float @func3(float %a, float %b, float %c, i1 %cond) {
; CHECK-LABEL: @func3(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[COND:%.*]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
; CHECK: cond.true:
; CHECK-NEXT: br label [[COND_END:%.*]]
; CHECK: cond.false:
; CHECK-NEXT: br label [[COND_END]]
; CHECK: cond.end:
; CHECK-NEXT: [[E_IN:%.*]] = phi float [ [[A:%.*]], [[COND_TRUE]] ], [ [[B:%.*]], [[COND_FALSE]] ]
; CHECK-NEXT: [[E:%.*]] = fadd fast float [[E_IN]], -2.000000e+00
; CHECK-NEXT: ret float [[E]]
;
entry:
br i1 %cond, label %cond.true, label %cond.false
cond.true:
%sub0 = fsub fast float %a, 2.0
br label %cond.end
cond.false:
%sub1 = fsub fast float %b, 2.0
br label %cond.end
cond.end:
%e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
ret float %e
}
define float @func4(float %a, float %b, float %c, i1 %cond) {
; CHECK-LABEL: @func4(
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[COND:%.*]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
; CHECK: cond.true:
; CHECK-NEXT: br label [[COND_END:%.*]]
; CHECK: cond.false:
; CHECK-NEXT: br label [[COND_END]]
; CHECK: cond.end:
; CHECK-NEXT: [[E_IN:%.*]] = phi float [ [[A:%.*]], [[COND_TRUE]] ], [ [[B:%.*]], [[COND_FALSE]] ]
; CHECK-NEXT: [[E:%.*]] = fadd float [[E_IN]], -2.000000e+00
; CHECK-NEXT: ret float [[E]]
;
entry:
br i1 %cond, label %cond.true, label %cond.false
cond.true:
%sub0 = fsub fast float %a, 2.0
br label %cond.end
cond.false:
%sub1 = fsub float %b, 2.0
br label %cond.end
cond.end:
%e = phi float [ %sub0, %cond.true ], [ %sub1, %cond.false ]
ret float %e
}