Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -march=x86-64 -mattr=+sse2  | FileCheck %s
      2 
      3 ; This test makes sure that the compiler does not crash with an
      4 ; assertion failure when trying to fold a vector shift left
      5 ; by immediate count if the type of the input vector is different
      6 ; to the result type.
      7 ;
      8 ; This happens for example when lowering a shift left of a MVT::v16i8 vector.
      9 ; This is custom lowered into the following sequence:
     10 ;     count << 5
     11 ;     A =  VSHLI(MVT::v8i16, r & (char16)15, 4)
     12 ;     B = BITCAST MVT::v16i8, A
     13 ;     VSELECT(r, B, count);
     14 ;     count += count
     15 ;     C = VSHLI(MVT::v8i16, r & (char16)63, 2)
     16 ;     D = BITCAST MVT::v16i8, C
     17 ;     r = VSELECT(r, C, count);
     18 ;     count += count
     19 ;     VSELECT(r, r+r, count);
     20 ;     count = count << 5;
     21 ;
     22 ; Where 'r' is a vector of type MVT::v16i8, and
     23 ; 'count' is the vector shift count.
     24 
     25 define <16 x i8> @do_not_crash(i8*, i32*, i64*, i32, i64, i8) {
     26 entry:
     27   store i8 %5, i8* %0
     28   %L5 = load i8, i8* %0
     29   %I8 = insertelement <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, i8 %L5, i32 7
     30   %B51 = shl <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, %I8
     31   ret <16 x i8> %B51
     32 }
     33 
     34 ; CHECK-LABEL: do_not_crash
     35 ; CHECK: ret
     36 
     37