File: aarch64-dup-ext-crash.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (88 lines) | stat: -rw-r--r-- 3,335 bytes parent folder | download | duplicates (6)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -o -| FileCheck %s

target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"

; This test covers a case where an AArch64 DUP instruction is generated with an
; invalid encoding, resulting in a crash. We don't care about the specific output
; here, only that this case no longer causes said crash.
define dso_local i32 @dupext_crashtest(i32 %e) local_unnamed_addr {
; CHECK-LABEL: dupext_crashtest:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    dup v0.2s, w0
; CHECK-NEXT:  .LBB0_1: // %vector.body
; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    ldr d1, [x8]
; CHECK-NEXT:    smull v1.2d, v0.2s, v1.2s
; CHECK-NEXT:    xtn v1.2s, v1.2d
; CHECK-NEXT:    str d1, [x8]
; CHECK-NEXT:    b .LBB0_1
entry:
  %conv314 = zext i32 %e to i64
  br label %vector.memcheck

vector.memcheck:                                  ; preds = %for.body.lr.ph
  br label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %conv314, i32 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %wide.load = load <2 x i32>, ptr undef, align 4
  %0 = zext <2 x i32> %wide.load to <2 x i64>
  %1 = mul nuw <2 x i64> %broadcast.splat, %0
  %2 = trunc <2 x i64> %1 to <2 x i32>
  %3 = select <2 x i1> undef, <2 x i32> undef, <2 x i32> %2
  %4 = bitcast ptr undef to ptr
  store <2 x i32> %3, ptr %4, align 4
  br label %vector.body
}

; This test got stuck in a loop hoisting the and to the load, and sinking it back to the mull
define i32 @dup_and_load(ptr %p, i1 %c) {
; CHECK-LABEL: dup_and_load:
; CHECK:       // %bb.0: // %entry
; CHECK-NEXT:    mov x8, x0
; CHECK-NEXT:    ldrb w0, [x0]
; CHECK-NEXT:    tbz w1, #0, .LBB1_3
; CHECK-NEXT:  // %bb.1: // %ph
; CHECK-NEXT:    dup v0.8h, w0
; CHECK-NEXT:    mov w9, wzr
; CHECK-NEXT:  .LBB1_2: // %vector.body
; CHECK-NEXT:    // =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    ldr d1, [x8]
; CHECK-NEXT:    add w9, w9, #1
; CHECK-NEXT:    cmp w9, #100
; CHECK-NEXT:    ushll v1.8h, v1.8b, #0
; CHECK-NEXT:    umull2 v2.4s, v0.8h, v1.8h
; CHECK-NEXT:    umull v1.4s, v0.4h, v1.4h
; CHECK-NEXT:    stp q1, q2, [x8]
; CHECK-NEXT:    b.lt .LBB1_2
; CHECK-NEXT:  .LBB1_3: // %end
; CHECK-NEXT:    ret
entry:
  %l = load i32, ptr %p
  %and255 = and i32 %l, 255
  br i1 %c, label %ph, label %end

ph:
  %broadcast.splatinsert = insertelement <8 x i32> poison, i32 %and255, i32 0
  %broadcast.splat = shufflevector <8 x i32> %broadcast.splatinsert, <8 x i32> poison, <8 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %iv = phi i32 [ 0, %ph ], [ %iv.next, %vector.body ]
  %wide.load = load <8 x i8>, ptr %p, align 4
  %0 = zext <8 x i8> %wide.load to <8 x i32>
  %1 = mul <8 x i32> %broadcast.splat, %0
  store <8 x i32> %1, ptr %p, align 4
  %iv.next = add i32 %iv, 1
  %e = icmp slt i32 %iv.next, 100
  br i1 %e, label %vector.body, label %end

end:
  ret i32 %and255
}