Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 
      2 
      3 ; Verify that DAGCombiner does not crash when checking if it is
      4 ; safe to fold the shuffles in function @sample_test according to rule
      5 ;  (shuffle (shuffle A, Undef, M0), Undef, M1) -> (shuffle A, Undef, M2)
      6 ;
      7 ; The DAGCombiner avoids folding shuffles if
      8 ; the resulting shuffle dag node is not legal for the target.
      9 ; That means, the shuffle must have legal type and legal mask.
     10 ;
     11 ; Before, the DAGCombiner forgot to check if the resulting shuffle
     12 ; was legal. It instead just called method
     13 ; 'X86TargetLowering::isShuffleMaskLegal'; however, that was not enough since
     14 ; that method always expect to have a valid vector type in input.
     15 ; As a consequence, compiling the function below would have caused a crash.
     16 
     17 define void @sample_test() {
     18   br i1 undef, label %5, label %1
     19 
     20 ; <label>:1                                       ; preds = %0
     21   %2 = load <4 x i8>, <4 x i8>* undef
     22   %3 = shufflevector <4 x i8> %2, <4 x i8> undef, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
     23   %4 = shufflevector <4 x i8> %3, <4 x i8> undef, <4 x i32> <i32 2, i32 3, i32 0, i32 1>
     24   store <4 x i8> %4, <4 x i8>* undef
     25   br label %5
     26 
     27 ; <label>:5                                       ; preds = %1, %0
     28   ret void
     29 }
     30 
     31