1; RUN: opt < %s -instcombine -S | FileCheck %s
2
3define float @test1(i1 %A) {
4EntryBlock:
5  %cf = select i1 %A, float 1.000000e+00, float 0.000000e+00
6  %op = fsub float 1.000000e+00, %cf
7  ret float %op
8; CHECK-LABEL: @test1(
9; CHECK: select i1 %A, float 0.000000e+00, float 1.000000e+00
10}
11
12define float @test2(i1 %A, float %B) {
13EntryBlock:
14  %cf = select i1 %A, float 1.000000e+00, float %B
15  %op = fadd float 2.000000e+00, %cf
16  ret float %op
17; CHECK-LABEL: @test2(
18; CHECK: [[OP:%.*]] = fadd float %B, 2.000000e+00
19; CHECK: select i1 %A, float 3.000000e+00, float [[OP]]
20}
21
22define float @test3(i1 %A, float %B) {
23EntryBlock:
24  %cf = select i1 %A, float 1.000000e+00, float %B
25  %op = fsub float 2.000000e+00, %cf
26  ret float %op
27; CHECK-LABEL: @test3(
28; CHECK: [[OP:%.*]] = fsub float 2.000000e+00, %B
29; CHECK: select i1 %A, float 1.000000e+00, float [[OP]]
30}
31
32define float @test4(i1 %A, float %B) {
33EntryBlock:
34  %cf = select i1 %A, float 1.000000e+00, float %B
35  %op = fmul float 2.000000e+00, %cf
36  ret float %op
37; CHECK-LABEL: @test4(
38; CHECK: [[OP:%.*]] = fmul float %B, 2.000000e+00
39; CHECK: select i1 %A, float 2.000000e+00, float [[OP]]
40}
41
42define float @test5(i1 %A, float %B) {
43EntryBlock:
44  %cf = select i1 %A, float 1.000000e+00, float %B
45  %op = fdiv float 2.000000e+00, %cf
46  ret float %op
47; CHECK-LABEL: @test5(
48; CHECK: [[OP:%.*]] = fdiv float 2.000000e+00, %B
49; CHECK: select i1 %A, float 2.000000e+00, float [[OP]]
50}
51
52define float @test6(i1 %A, float %B) {
53EntryBlock:
54  %cf = select i1 %A, float 1.000000e+00, float %B
55  %op = fdiv float %cf, 2.000000e+00
56  ret float %op
57; CHECK-LABEL: @test6(
58; CHECK: [[OP:%.*]] = fmul float %B, 5.000000e-01
59; CHECK: select i1 %A, float 5.000000e-01, float [[OP]]
60}
61
62define float @test7(i1 %A, float %B) {
63EntryBlock:
64  %cf = select i1 %A, float 1.000000e+00, float %B
65  %op = fdiv float %cf, 3.000000e+00
66  ret float %op
67; CHECK-LABEL: @test7(
68; CHECK: [[OP:%.*]] = fdiv float %B, 3.000000e+00
69; CHECK: select i1 %A, float 0x3FD5555560000000, float [[OP]]
70}
71
72