File: shuffle-combine-crash.ll

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,436 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (30 lines) | stat: -rw-r--r-- 1,254 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 

; Verify that DAGCombiner does not crash when checking if it is
; safe to fold the shuffles in function @sample_test according to rule
;  (shuffle (shuffle A, Undef, M0), Undef, M1) -> (shuffle A, Undef, M2)
;
; The DAGCombiner avoids folding shuffles if
; the resulting shuffle dag node is not legal for the target.
; That means, the shuffle must have legal type and legal mask.
;
; Before, the DAGCombiner forgot to check if the resulting shuffle
; was legal. It instead just called method
; 'X86TargetLowering::isShuffleMaskLegal'; however, that was not enough since
; that method always expect to have a valid vector type in input.
; As a consequence, compiling the function below would have caused a crash.

define void @sample_test() {
  br i1 undef, label %5, label %1

; <label>:1                                       ; preds = %0
  %2 = load <4 x i8>, <4 x i8>* undef
  %3 = shufflevector <4 x i8> %2, <4 x i8> undef, <4 x i32> <i32 2, i32 2, i32 0, i32 0>
  %4 = shufflevector <4 x i8> %3, <4 x i8> undef, <4 x i32> <i32 2, i32 3, i32 0, i32 1>
  store <4 x i8> %4, <4 x i8>* undef
  br label %5

; <label>:5                                       ; preds = %1, %0
  ret void
}