xref: /llvm-project/llvm/test/CodeGen/X86/fast-isel-bitcast-crash.ll (revision 5ca77541446d7040638b53e0ddff3f76ee005681)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -fast-isel -O1 | FileCheck %s
3
4; This used to crash due to the bitcast in the entry block reusing the vreg
5; from its input. This resulted in known bits being calculated on the v2i64
6; type. But the second basic block tried to use them with a v8i16 type. This
7; was fixed by emitting a reg-reg copy for the bitcast so the vreg type will
8; be seen the same in both basic blocks.
9
10; We need the entry block to fall out of fast isel after selecting the bitcast.
11; The shuffle vector guarantees that. The zext gives us a useful known bits
12; value. We also need the second basic block to fall out of fast isel which the
13; intrinsic guarantees.
14
15define <8 x i16> @bitcast_crash(i32 %arg, <8 x i16> %x, i1 %c) {
16; CHECK-LABEL: bitcast_crash:
17; CHECK:       # %bb.0: # %bb
18; CHECK-NEXT:    movd %edi, %xmm1
19; CHECK-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[0,1,0,1]
20; CHECK-NEXT:    testb $1, %sil
21; CHECK-NEXT:    je .LBB0_2
22; CHECK-NEXT:  # %bb.1: # %bb1
23; CHECK-NEXT:    psraw %xmm1, %xmm0
24; CHECK-NEXT:    retq
25; CHECK-NEXT:  .LBB0_2: # %bb2
26; CHECK-NEXT:    movdqa %xmm1, %xmm0
27; CHECK-NEXT:    retq
28bb:
29  %tmp = zext i32 %arg to i64
30  %tmp1 = insertelement <2 x i64> undef, i64 %tmp, i32 0
31  %tmp2 = shufflevector <2 x i64> %tmp1, <2 x i64> undef, <2 x i32> zeroinitializer
32  %tmp5 = bitcast <2 x i64> %tmp2 to <8 x i16>
33  br i1 %c, label %bb1, label %bb2
34
35bb1:                                              ; preds = %bb8, %bb6
36  %tmp9 = call <8 x i16> @llvm.x86.sse2.psra.w(<8 x i16> %x, <8 x i16> %tmp5)
37  ret <8 x i16> %tmp9
38
39bb2:
40  ret <8 x i16> %tmp5
41}
42
43declare <8 x i16> @llvm.x86.sse2.psra.w(<8 x i16>, <8 x i16>)
44