1; RUN: opt -early-cse -earlycse-debug-hash -S < %s | FileCheck %s
2
3target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
4target triple = "aarch64"
5
6; This test checks that SimplifyInstruction does not blow up in the face of
7; a scalable shufflevector. vscale is a constant value known only at runtime.
8; Therefore, it is not possible to know the concrete value of, or the length
9; of the mask at compile time. Simplifications that depend on the value
10; of the mask cannot be performed.
11
12; Given the fact that the value of the mask is unknown at compile time for
13; scalable vectors, very few simplifications will be done. Here, we want to
14; see that the instruction can be passed to SimplifyInstruction and not crash
15; the compiler. It happens to be the case that this will be the result.
16
17; CHECK-LABEL: define <vscale x 8 x i1> @vscale_version()
18; CHECK-NEXT: ret <vscale x 8 x i1> shufflevector (<vscale x 8 x i1> insertelement (<vscale x 8 x i1> undef, i1 true, i32 0), <vscale x 8 x i1> undef, <vscale x 8 x i32> zeroinitializer)
19
20define <vscale x 8 x i1> @vscale_version() {
21  %splatter = insertelement <vscale x 8 x i1> undef, i1 true, i32 0
22  %foo = shufflevector <vscale x 8 x i1> %splatter,
23                       <vscale x 8 x i1> undef,
24                       <vscale x 8 x i32> zeroinitializer
25  ret <vscale x 8 x i1> %foo
26}
27
28; The non-scalable version should be optimized as normal.
29
30; CHECK-LABEL: define <8 x i1> @fixed_length_version() {
31; CHECK-NEXT:  ret <8 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>
32define <8 x i1> @fixed_length_version() {
33  %splatter = insertelement <8 x i1> undef, i1 true, i32 0
34  %foo = shufflevector <8 x i1> %splatter,
35                       <8 x i1> undef,
36                       <8 x i32> zeroinitializer
37  ret <8 x i1> %foo
38}
39
40