1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 define float @test1(i1 %A) {
5 %cf = select i1 %A, float 1.000000e+00, float 0.000000e+00
6 %op = fsub float 1.000000e+00, %cf
9 ; CHECK: select i1 %A, float 0.000000e+00, float 1.000000e+00
12 define float @test2(i1 %A, float %B) {
14 %cf = select i1 %A, float 1.000000e+00, float %B
15 %op = fadd float 2.000000e+00, %cf
17 ; CHECK-LABEL: @test2(
18 ; CHECK: [[OP:%.*]] = fadd float %B, 2.000000e+00
19 ; CHECK: select i1 %A, float 3.000000e+00, float [[OP]]
22 define float @test3(i1 %A, float %B) {
24 %cf = select i1 %A, float 1.000000e+00, float %B
25 %op = fsub float 2.000000e+00, %cf
27 ; CHECK-LABEL: @test3(
28 ; CHECK: [[OP:%.*]] = fsub float 2.000000e+00, %B
29 ; CHECK: select i1 %A, float 1.000000e+00, float [[OP]]
32 define float @test4(i1 %A, float %B) {
34 %cf = select i1 %A, float 1.000000e+00, float %B
35 %op = fmul float 2.000000e+00, %cf
37 ; CHECK-LABEL: @test4(
38 ; CHECK: [[OP:%.*]] = fmul float %B, 2.000000e+00
39 ; CHECK: select i1 %A, float 2.000000e+00, float [[OP]]
42 define float @test5(i1 %A, float %B) {
44 %cf = select i1 %A, float 1.000000e+00, float %B
45 %op = fdiv float 2.000000e+00, %cf
47 ; CHECK-LABEL: @test5(
48 ; CHECK: [[OP:%.*]] = fdiv float 2.000000e+00, %B
49 ; CHECK: select i1 %A, float 2.000000e+00, float [[OP]]
52 define float @test6(i1 %A, float %B) {
54 %cf = select i1 %A, float 1.000000e+00, float %B
55 %op = fdiv float %cf, 2.000000e+00
57 ; CHECK-LABEL: @test6(
58 ; CHECK: [[OP:%.*]] = fmul float %B, 5.000000e-01
59 ; CHECK: select i1 %A, float 5.000000e-01, float [[OP]]
62 define float @test7(i1 %A, float %B) {
64 %cf = select i1 %A, float 1.000000e+00, float %B
65 %op = fdiv float %cf, 3.000000e+00
67 ; CHECK-LABEL: @test7(
68 ; CHECK: [[OP:%.*]] = fdiv float %B, 3.000000e+00
69 ; CHECK: select i1 %A, float 0x3FD5555560000000, float [[OP]]