%s3 = select i1 %s2, i1 %c3, i1 false
ret i1 %s3
}
+
+define i1 @logical_and_icmp_clamp(<4 x i32> %x) {
+; CHECK-LABEL: @logical_and_icmp_clamp(
+; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 0
+; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i32> [[X]], i32 1
+; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
+; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i32> [[X]], i32 3
+; CHECK-NEXT: [[C0:%.*]] = icmp slt i32 [[X0]], 42
+; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[X1]], 42
+; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[X2]], 42
+; CHECK-NEXT: [[C3:%.*]] = icmp slt i32 [[X3]], 42
+; CHECK-NEXT: [[D0:%.*]] = icmp sgt i32 [[X0]], 17
+; CHECK-NEXT: [[D1:%.*]] = icmp sgt i32 [[X1]], 17
+; CHECK-NEXT: [[D2:%.*]] = icmp sgt i32 [[X2]], 17
+; CHECK-NEXT: [[D3:%.*]] = icmp sgt i32 [[X3]], 17
+; CHECK-NEXT: [[S1:%.*]] = select i1 [[C0]], i1 [[C1]], i1 false
+; CHECK-NEXT: [[S2:%.*]] = select i1 [[S1]], i1 [[C2]], i1 false
+; CHECK-NEXT: [[S3:%.*]] = select i1 [[S2]], i1 [[C3]], i1 false
+; CHECK-NEXT: [[S4:%.*]] = select i1 [[S3]], i1 [[D0]], i1 false
+; CHECK-NEXT: [[S5:%.*]] = select i1 [[S4]], i1 [[D1]], i1 false
+; CHECK-NEXT: [[S6:%.*]] = select i1 [[S5]], i1 [[D2]], i1 false
+; CHECK-NEXT: [[S7:%.*]] = select i1 [[S6]], i1 [[D3]], i1 false
+; CHECK-NEXT: ret i1 [[S7]]
+;
+ %x0 = extractelement <4 x i32> %x, i32 0
+ %x1 = extractelement <4 x i32> %x, i32 1
+ %x2 = extractelement <4 x i32> %x, i32 2
+ %x3 = extractelement <4 x i32> %x, i32 3
+ %c0 = icmp slt i32 %x0, 42
+ %c1 = icmp slt i32 %x1, 42
+ %c2 = icmp slt i32 %x2, 42
+ %c3 = icmp slt i32 %x3, 42
+ %d0 = icmp sgt i32 %x0, 17
+ %d1 = icmp sgt i32 %x1, 17
+ %d2 = icmp sgt i32 %x2, 17
+ %d3 = icmp sgt i32 %x3, 17
+ %s1 = select i1 %c0, i1 %c1, i1 false
+ %s2 = select i1 %s1, i1 %c2, i1 false
+ %s3 = select i1 %s2, i1 %c3, i1 false
+ %s4 = select i1 %s3, i1 %d0, i1 false
+ %s5 = select i1 %s4, i1 %d1, i1 false
+ %s6 = select i1 %s5, i1 %d2, i1 false
+ %s7 = select i1 %s6, i1 %d3, i1 false
+ ret i1 %s7
+}