1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2 | FileCheck %s --check-prefixes=SSE
3 ; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2 | FileCheck %s --check-prefixes=AVX
5 ; PR114901 - ensure that the ASHR node doesn't commute the operands.
6 define i1 @PR114901(<4 x i32> %a) {
7 ; SSE-LABEL: define i1 @PR114901(
8 ; SSE-SAME: <4 x i32> [[A:%.*]]) #[[ATTR0:[0-9]+]] {
9 ; SSE-NEXT: [[E1:%.*]] = extractelement <4 x i32> [[A]], i32 1
10 ; SSE-NEXT: [[E3:%.*]] = extractelement <4 x i32> [[A]], i32 3
11 ; SSE-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[E1]], -8
12 ; SSE-NEXT: [[CMP3:%.*]] = icmp sgt i32 [[E3]], 42
13 ; SSE-NEXT: [[R:%.*]] = ashr i1 [[CMP3]], [[CMP1]]
14 ; SSE-NEXT: ret i1 [[R]]
16 ; AVX-LABEL: define i1 @PR114901(
17 ; AVX-SAME: <4 x i32> [[A:%.*]]) #[[ATTR0:[0-9]+]] {
18 ; AVX-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[A]], <i32 poison, i32 -8, i32 poison, i32 42>
19 ; AVX-NEXT: [[SHIFT:%.*]] = shufflevector <4 x i1> [[TMP1]], <4 x i1> poison, <4 x i32> <i32 poison, i32 3, i32 poison, i32 poison>
20 ; AVX-NEXT: [[TMP2:%.*]] = ashr <4 x i1> [[SHIFT]], [[TMP1]]
21 ; AVX-NEXT: [[R:%.*]] = extractelement <4 x i1> [[TMP2]], i64 1
22 ; AVX-NEXT: ret i1 [[R]]
24 %e1 = extractelement <4 x i32> %a, i32 1
25 %e3 = extractelement <4 x i32> %a, i32 3
26 %cmp1 = icmp sgt i32 %e1, 4294967288
27 %cmp3 = icmp sgt i32 %e3, 42
28 %r = ashr i1 %cmp3, %cmp1
32 define i1 @PR114901_flip(<4 x i32> %a) {
33 ; SSE-LABEL: define i1 @PR114901_flip(
34 ; SSE-SAME: <4 x i32> [[A:%.*]]) #[[ATTR0]] {
35 ; SSE-NEXT: [[E1:%.*]] = extractelement <4 x i32> [[A]], i32 1
36 ; SSE-NEXT: [[E3:%.*]] = extractelement <4 x i32> [[A]], i32 3
37 ; SSE-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[E1]], -8
38 ; SSE-NEXT: [[CMP3:%.*]] = icmp sgt i32 [[E3]], 42
39 ; SSE-NEXT: [[R:%.*]] = ashr i1 [[CMP1]], [[CMP3]]
40 ; SSE-NEXT: ret i1 [[R]]
42 ; AVX-LABEL: define i1 @PR114901_flip(
43 ; AVX-SAME: <4 x i32> [[A:%.*]]) #[[ATTR0]] {
44 ; AVX-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[A]], <i32 poison, i32 -8, i32 poison, i32 42>
45 ; AVX-NEXT: [[SHIFT:%.*]] = shufflevector <4 x i1> [[TMP1]], <4 x i1> poison, <4 x i32> <i32 poison, i32 3, i32 poison, i32 poison>
46 ; AVX-NEXT: [[TMP2:%.*]] = ashr <4 x i1> [[TMP1]], [[SHIFT]]
47 ; AVX-NEXT: [[R:%.*]] = extractelement <4 x i1> [[TMP2]], i64 1
48 ; AVX-NEXT: ret i1 [[R]]
50 %e1 = extractelement <4 x i32> %a, i32 1
51 %e3 = extractelement <4 x i32> %a, i32 3
52 %cmp1 = icmp sgt i32 %e1, 4294967288
53 %cmp3 = icmp sgt i32 %e3, 42
54 %r = ashr i1 %cmp1, %cmp3