1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=vector-combine -S %s | FileCheck %s
4 ; Negative test for extract + cmp + binop - don't try this with scalable vectors.
5 ; Moved from X86/extract-cmp-binop.ll
7 define i1 @extract_cmp_binop(<vscale x 4 x i32> %a) {
8 ; CHECK-LABEL: @extract_cmp_binop(
9 ; CHECK-NEXT: [[E1:%.*]] = extractelement <vscale x 4 x i32> [[A:%.*]], i32 3
10 ; CHECK-NEXT: [[E2:%.*]] = extractelement <vscale x 4 x i32> [[A]], i32 1
11 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i32 [[E1]], 42
12 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i32 [[E2]], -8
13 ; CHECK-NEXT: [[R:%.*]] = xor i1 [[CMP1]], [[CMP2]]
14 ; CHECK-NEXT: ret i1 [[R]]
16 %e1 = extractelement <vscale x 4 x i32> %a, i32 3
17 %e2 = extractelement <vscale x 4 x i32> %a, i32 1
18 %cmp1 = icmp sgt i32 %e1, 42
19 %cmp2 = icmp sgt i32 %e2, -8
20 %r = xor i1 %cmp1, %cmp2
24 ; Test that VectorCombine doesn't try to create a shufflevector for
25 ; an extract-extract pattern on a scalable vector type.
26 define i32 @extract_extract(<vscale x 4 x i32> %vec) {
27 ; CHECK-LABEL: @extract_extract(
28 ; CHECK-NEXT: [[ELT0:%.*]] = extractelement <vscale x 4 x i32> [[VEC:%.*]], i32 0
29 ; CHECK-NEXT: [[ELT1:%.*]] = extractelement <vscale x 4 x i32> [[VEC]], i32 1
30 ; CHECK-NEXT: [[IDX:%.*]] = add i32 [[ELT0]], [[ELT1]]
31 ; CHECK-NEXT: [[ELTIDX:%.*]] = extractelement <vscale x 4 x i32> [[VEC]], i32 [[IDX]]
32 ; CHECK-NEXT: ret i32 [[ELTIDX]]
34 %elt0 = extractelement <vscale x 4 x i32> %vec, i32 0
35 %elt1 = extractelement <vscale x 4 x i32> %vec, i32 1
36 %idx = add i32 %elt0, %elt1
37 %eltidx = extractelement <vscale x 4 x i32> %vec, i32 %idx