1; RUN: opt -instcombine -S < %s | FileCheck %s
2
3; CHECK: @foo1
4define float @foo1(float %a) #0 {
5; CHECK-NOT: xor
6  %b = fcmp ogt float %a, 0.000000e+00
7  %c = select i1 %b, float %a, float 0.000000e+00
8  %d = fcmp olt float %c, 1.000000e+00
9  %f = select i1 %d, float %c, float 1.000000e+00
10  ret float %f
11}
12
13; CHECK: @foo2
14define float @foo2(float %a) #0 {
15; CHECK-NOT: xor
16  %b = fcmp ogt float %a, 0.000000e+00
17  %c = select i1 %b, float %a, float 0.000000e+00
18  %d = fcmp olt float %c, 1.000000e+00
19  %e = select i1 %b, float %a, float 0.000000e+00
20  %f = select i1 %d, float %e, float 1.000000e+00
21  ret float %f
22}
23
24; CHECK-LABEL: @foo3
25define <2 x i32> @foo3(<2 x i1> %vec_bool, i1 %bool, <2 x i32> %V) {
26; CHECK: %[[sel0:.*]] = select <2 x i1> %vec_bool, <2 x i32> zeroinitializer, <2 x i32> %V
27; CHECK: %[[sel1:.*]] = select i1 %bool, <2 x i32> %[[sel0]], <2 x i32> %V
28; CHECK: ret <2 x i32> %[[sel1]]
29  %sel0 = select <2 x i1> %vec_bool, <2 x i32> zeroinitializer, <2 x i32> %V
30  %sel1 = select i1 %bool, <2 x i32> %sel0, <2 x i32> %V
31  ret <2 x i32> %sel1
32}
33
34attributes #0 = { nounwind readnone ssp uwtable }
35