xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/shift-combine-crash.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 > /dev/null
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Verify that DAGCombiner doesn't crash with an assertion failure in the
4*9880d681SAndroid Build Coastguard Worker; attempt to cast a ISD::UNDEF node to a ConstantSDNode.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; During type legalization, the vector shift operation in function @test1 is
7*9880d681SAndroid Build Coastguard Worker; split into two legal shifts that work on <2 x i64> elements.
8*9880d681SAndroid Build Coastguard Worker; The first shift of the legalized sequence would be a shift by all undefs.
9*9880d681SAndroid Build Coastguard Worker; DAGCombiner will then try to simplify the vector shift and check if the
10*9880d681SAndroid Build Coastguard Worker; vector of shift counts is a splat. Make sure that llc doesn't crash
11*9880d681SAndroid Build Coastguard Worker; at that stage.
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdefine <4 x i64> @test1(<4 x i64> %A) {
15*9880d681SAndroid Build Coastguard Worker  %shl = shl <4 x i64> %A, <i64 undef, i64 undef, i64 1, i64 2>
16*9880d681SAndroid Build Coastguard Worker  ret <4 x i64> %shl
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Also, verify that DAGCombiner doesn't crash when trying to combine shifts
20*9880d681SAndroid Build Coastguard Worker; with different combinations of undef elements in the vector shift count.
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerdefine <4 x i64> @test2(<4 x i64> %A) {
23*9880d681SAndroid Build Coastguard Worker  %shl = shl <4 x i64> %A, <i64 2, i64 3, i64 undef, i64 undef>
24*9880d681SAndroid Build Coastguard Worker  ret <4 x i64> %shl
25*9880d681SAndroid Build Coastguard Worker}
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerdefine <4 x i64> @test3(<4 x i64> %A) {
28*9880d681SAndroid Build Coastguard Worker  %shl = shl <4 x i64> %A, <i64 2, i64 undef, i64 3, i64 undef>
29*9880d681SAndroid Build Coastguard Worker  ret <4 x i64> %shl
30*9880d681SAndroid Build Coastguard Worker}
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Workerdefine <4 x i64> @test4(<4 x i64> %A) {
33*9880d681SAndroid Build Coastguard Worker  %shl = shl <4 x i64> %A, <i64 undef, i64 2, i64 undef, i64 3>
34*9880d681SAndroid Build Coastguard Worker  ret <4 x i64> %shl
35*9880d681SAndroid Build Coastguard Worker}
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerdefine <4 x i64> @test5(<4 x i64> %A) {
38*9880d681SAndroid Build Coastguard Worker  %shl = shl <4 x i64> %A, <i64 2, i64 undef, i64 undef, i64 undef>
39*9880d681SAndroid Build Coastguard Worker  ret <4 x i64> %shl
40*9880d681SAndroid Build Coastguard Worker}
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerdefine <4 x i64> @test6(<4 x i64> %A) {
43*9880d681SAndroid Build Coastguard Worker  %shl = shl <4 x i64> %A, <i64 undef, i64 undef, i64 3, i64 undef>
44*9880d681SAndroid Build Coastguard Worker  ret <4 x i64> %shl
45*9880d681SAndroid Build Coastguard Worker}
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Workerdefine <4 x i64> @test7(<4 x i64> %A) {
48*9880d681SAndroid Build Coastguard Worker  %shl = shl <4 x i64> %A, <i64 undef, i64 undef, i64 undef, i64 3>
49*9880d681SAndroid Build Coastguard Worker  ret <4 x i64> %shl
50*9880d681SAndroid Build Coastguard Worker}
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workerdefine <4 x i64> @test8(<4 x i64> %A) {
53*9880d681SAndroid Build Coastguard Worker  %shl = shl <4 x i64> %A, <i64 undef, i64 undef, i64 undef, i64 undef>
54*9880d681SAndroid Build Coastguard Worker  ret <4 x i64> %shl
55*9880d681SAndroid Build Coastguard Worker}
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker
58