1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 | FileCheck %s 3 4; Verify that DAGCombiner does not crash when checking if it is 5; safe to fold the shuffles in function @sample_test according to rule 6; (shuffle (shuffle A, Undef, M0), Undef, M1) -> (shuffle A, Undef, M2) 7; 8; The DAGCombiner avoids folding shuffles if 9; the resulting shuffle dag node is not legal for the target. 10; That means, the shuffle must have legal type and legal mask. 11; 12; Before, the DAGCombiner forgot to check if the resulting shuffle 13; was legal. It instead just called method 14; 'X86TargetLowering::isShuffleMaskLegal'; however, that was not enough since 15; that method always expect to have a valid vector type in input. 16; As a consequence, compiling the function below would have caused a crash. 17 18define void @sample_test() { 19; CHECK-LABEL: sample_test: 20; CHECK: # %bb.0: 21; CHECK-NEXT: xorl %eax, %eax 22; CHECK-NEXT: testb %al, %al 23; CHECK-NEXT: jne .LBB0_2 24; CHECK-NEXT: # %bb.1: 25; CHECK-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero 26; CHECK-NEXT: punpcklbw {{.*#+}} xmm0 = xmm0[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7] 27; CHECK-NEXT: pshuflw {{.*#+}} xmm0 = xmm0[0,2,2,3,4,5,6,7] 28; CHECK-NEXT: movd %xmm0, (%rax) 29; CHECK-NEXT: .LBB0_2: 30; CHECK-NEXT: retq 31 br i1 undef, label %5, label %1 32 33; <label>:1 ; preds = %0 34 %2 = load <4 x i8>, <4 x i8>* undef 35 %3 = shufflevector <4 x i8> %2, <4 x i8> undef, <4 x i32> <i32 2, i32 2, i32 0, i32 0> 36 %4 = shufflevector <4 x i8> %3, <4 x i8> undef, <4 x i32> <i32 2, i32 3, i32 0, i32 1> 37 store <4 x i8> %4, <4 x i8>* undef 38 br label %5 39 40; <label>:5 ; preds = %1, %0 41 ret void 42} 43 44