File: typepromotion-cost.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (103 lines) | stat: -rw-r--r-- 3,649 bytes parent folder | download | duplicates (10)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -o - %s -mtriple=aarch64 | FileCheck %s --check-prefix=CHECK-O2
; RUN: llc -o - %s -mtriple=aarch64 -O3 | FileCheck %s --check-prefix=CHECK-O3

%struct.S = type { i32, i16 }
define i32 @needless_promotion(ptr nocapture noundef readonly %S, i64 noundef %red_cost) {
; CHECK-O2-LABEL: needless_promotion:
; CHECK-O2:       // %bb.0: // %entry
; CHECK-O2-NEXT:    ldrsh w8, [x0, #4]
; CHECK-O2-NEXT:    tbnz w8, #31, .LBB0_3
; CHECK-O2-NEXT:  // %bb.1: // %lor.rhs
; CHECK-O2-NEXT:    cbz x1, .LBB0_5
; CHECK-O2-NEXT:  // %bb.2:
; CHECK-O2-NEXT:    mov w9, #2
; CHECK-O2-NEXT:    b .LBB0_4
; CHECK-O2-NEXT:  .LBB0_3:
; CHECK-O2-NEXT:    mov w9, #1
; CHECK-O2-NEXT:  .LBB0_4: // %lor.end.sink.split
; CHECK-O2-NEXT:    cmp w8, w9
; CHECK-O2-NEXT:    cset w0, eq
; CHECK-O2-NEXT:    ret
; CHECK-O2-NEXT:  .LBB0_5:
; CHECK-O2-NEXT:    mov w0, wzr
; CHECK-O2-NEXT:    ret
;
; CHECK-O3-LABEL: needless_promotion:
; CHECK-O3:       // %bb.0: // %entry
; CHECK-O3-NEXT:    ldrsh w8, [x0, #4]
; CHECK-O3-NEXT:    tbnz w8, #31, .LBB0_3
; CHECK-O3-NEXT:  // %bb.1: // %lor.rhs
; CHECK-O3-NEXT:    cbz x1, .LBB0_4
; CHECK-O3-NEXT:  // %bb.2:
; CHECK-O3-NEXT:    mov w9, #2
; CHECK-O3-NEXT:    cmp w8, w9
; CHECK-O3-NEXT:    cset w0, eq
; CHECK-O3-NEXT:    ret
; CHECK-O3-NEXT:  .LBB0_3:
; CHECK-O3-NEXT:    mov w9, #1
; CHECK-O3-NEXT:    cmp w8, w9
; CHECK-O3-NEXT:    cset w0, eq
; CHECK-O3-NEXT:    ret
; CHECK-O3-NEXT:  .LBB0_4:
; CHECK-O3-NEXT:    mov w0, wzr
; CHECK-O3-NEXT:    ret
entry:
  %ident = getelementptr inbounds %struct.S, ptr %S, i64 0, i32 1
  %0 = load i16, ptr %ident, align 8
  %cmp = icmp slt i16 %0, 0
  br i1 %cmp, label %lor.end.sink.split, label %lor.rhs

lor.rhs:                                          ; preds = %entry
  %cmp3.not = icmp eq i64 %red_cost, 0
  br i1 %cmp3.not, label %lor.end, label %lor.end.sink.split

lor.end.sink.split:                               ; preds = %lor.rhs, %entry
  %.sink12 = phi i16 [ 1, %entry ], [ 2, %lor.rhs ]
  %cmp1 = icmp eq i16 %0, %.sink12
  %phi.cast = zext i1 %cmp1 to i32
  br label %lor.end

lor.end:                                          ; preds = %lor.end.sink.split, %lor.rhs
  %.shrunk = phi i32 [ 0, %lor.rhs ], [ %phi.cast, %lor.end.sink.split ]
  ret i32 %.shrunk
}

define i8 @loopcmp(ptr nocapture noundef readonly %x, i8 noundef %y) {
; CHECK-O2-LABEL: loopcmp:
; CHECK-O2:       // %bb.0: // %entry
; CHECK-O2-NEXT:    and w9, w1, #0xff
; CHECK-O2-NEXT:  .LBB1_1: // %while.cond
; CHECK-O2-NEXT:    // =>This Inner Loop Header: Depth=1
; CHECK-O2-NEXT:    ldrb w8, [x0], #1
; CHECK-O2-NEXT:    cmp w8, w9
; CHECK-O2-NEXT:    b.lo .LBB1_1
; CHECK-O2-NEXT:  // %bb.2: // %while.end
; CHECK-O2-NEXT:    mov w0, w8
; CHECK-O2-NEXT:    ret
;
; CHECK-O3-LABEL: loopcmp:
; CHECK-O3:       // %bb.0: // %entry
; CHECK-O3-NEXT:    and w9, w1, #0xff
; CHECK-O3-NEXT:  .LBB1_1: // %while.cond
; CHECK-O3-NEXT:    // =>This Inner Loop Header: Depth=1
; CHECK-O3-NEXT:    ldrb w8, [x0], #1
; CHECK-O3-NEXT:    cmp w8, w9
; CHECK-O3-NEXT:    b.lo .LBB1_1
; CHECK-O3-NEXT:  // %bb.2: // %while.end
; CHECK-O3-NEXT:    mov w0, w8
; CHECK-O3-NEXT:    ret
entry:
  br label %while.cond

while.cond:                                       ; preds = %while.cond, %entry
  %a.0.in = phi ptr [ %x, %entry ], [ %x.addr.0, %while.cond ]
  %a.0 = load i8, ptr %a.0.in, align 1
  %cmp = icmp ult i8 %a.0, %y
  %x.addr.0 = getelementptr inbounds i8, ptr %a.0.in, i64 1
  br i1 %cmp, label %while.cond, label %while.end

while.end:                                        ; preds = %while.cond
  ret i8 %a.0
}