[InstCombine] Signed saturation patterns
[llvm-core.git] / test / Transforms / InstCombine / select-select.ll
blob768d1c47c20965688623e5381e624d49f02ba578
1 ; RUN: opt -instcombine -S < %s | FileCheck %s
3 ; CHECK: @foo1
4 define 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
13 ; CHECK: @foo2
14 define 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
24 ; CHECK-LABEL: @foo3
25 define <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
34 attributes #0 = { nounwind readnone ssp uwtable }