File: mve-vadc-vsbc-spill.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 (106 lines) | stat: -rw-r--r-- 4,935 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s -mtriple thumbv8.1m.main-arm-none-eabihf -mattr=+mve | FileCheck %s

declare void @use_int32x4_t(<4 x i32>)

; A 256-bit addition, with the two halves of the result passed to function
; calls to spill the carry bit out of FPSCR.
define void @add_256(<4 x i32> %a_low, <4 x i32> %a_high, <4 x i32> %b_low, <4 x i32> %b_high) {
; CHECK-LABEL: add_256:
; CHECK:       @ %bb.0: @ %entry
; CHECK-NEXT:    .save {r7, lr}
; CHECK-NEXT:    push {r7, lr}
; CHECK-NEXT:    .vsave {d8, d9, d10, d11}
; CHECK-NEXT:    vpush {d8, d9, d10, d11}
; CHECK-NEXT:    .pad #8
; CHECK-NEXT:    sub sp, #8
; CHECK-NEXT:    vadci.i32 q0, q0, q2
; CHECK-NEXT:    vmov q4, q3
; CHECK-NEXT:    vmov q5, q1
; CHECK-NEXT:    vstr fpscr_nzcvqc, [sp, #4] @ 4-byte Spill
; CHECK-NEXT:    bl use_int32x4_t
; CHECK-NEXT:    vldr fpscr_nzcvqc, [sp, #4] @ 4-byte Reload
; CHECK-NEXT:    vadc.i32 q0, q5, q4
; CHECK-NEXT:    add sp, #8
; CHECK-NEXT:    vpop {d8, d9, d10, d11}
; CHECK-NEXT:    pop.w {r7, lr}
; CHECK-NEXT:    b use_int32x4_t
entry:
  %adc_low = tail call { <4 x i32>, i32 } @llvm.arm.mve.vadc.v4i32(<4 x i32> %a_low, <4 x i32> %b_low, i32 0)
  %carry = extractvalue { <4 x i32>, i32 } %adc_low, 1
  %result_low = extractvalue { <4 x i32>, i32 } %adc_low, 0
  tail call void @use_int32x4_t(<4 x i32> %result_low)
  %adc_high = tail call { <4 x i32>, i32 } @llvm.arm.mve.vadc.v4i32(<4 x i32> %a_high, <4 x i32> %b_high, i32 %carry)
  %result_high = extractvalue { <4 x i32>, i32 } %adc_high, 0
  tail call void @use_int32x4_t(<4 x i32> %result_high)
  ret void
}

; A 256-bit subtraction, with the two halves of the result passed to function
; calls to spill the carry bit out of FPSCR.
define void @sub_256(<4 x i32> %a_low, <4 x i32> %a_high, <4 x i32> %b_low, <4 x i32> %b_high) {
; CHECK-LABEL: sub_256:
; CHECK:       @ %bb.0: @ %entry
; CHECK-NEXT:    .save {r7, lr}
; CHECK-NEXT:    push {r7, lr}
; CHECK-NEXT:    .vsave {d8, d9, d10, d11}
; CHECK-NEXT:    vpush {d8, d9, d10, d11}
; CHECK-NEXT:    .pad #8
; CHECK-NEXT:    sub sp, #8
; CHECK-NEXT:    vsbci.i32 q0, q0, q2
; CHECK-NEXT:    vmov q4, q3
; CHECK-NEXT:    vmov q5, q1
; CHECK-NEXT:    vstr fpscr_nzcvqc, [sp, #4] @ 4-byte Spill
; CHECK-NEXT:    bl use_int32x4_t
; CHECK-NEXT:    vldr fpscr_nzcvqc, [sp, #4] @ 4-byte Reload
; CHECK-NEXT:    vsbc.i32 q0, q5, q4
; CHECK-NEXT:    add sp, #8
; CHECK-NEXT:    vpop {d8, d9, d10, d11}
; CHECK-NEXT:    pop.w {r7, lr}
; CHECK-NEXT:    b use_int32x4_t
entry:
  %adc_low = tail call { <4 x i32>, i32 } @llvm.arm.mve.vsbc.v4i32(<4 x i32> %a_low, <4 x i32> %b_low, i32 536870912)
  %carry = extractvalue { <4 x i32>, i32 } %adc_low, 1
  %result_low = extractvalue { <4 x i32>, i32 } %adc_low, 0
  tail call void @use_int32x4_t(<4 x i32> %result_low)
  %adc_high = tail call { <4 x i32>, i32 } @llvm.arm.mve.vsbc.v4i32(<4 x i32> %a_high, <4 x i32> %b_high, i32 %carry)
  %result_high = extractvalue { <4 x i32>, i32 } %adc_high, 0
  tail call void @use_int32x4_t(<4 x i32> %result_high)
  ret void
}

; The carry-out of the first VADC intrinsic call is used by two other VADCs,
; both of which will modify FPSCR, so it must be spilled and reloaded.
; Missed optimisation: the first VLDR isn't needed, because the carry bit is
; already in FPSCR.
define <4 x i32> @multiple_uses_of_carry_bit(<4 x i32> %a_low, <4 x i32> %a_high, <4 x i32> %b_low, <4 x i32> %b_high, <4 x i32> %a_high_2, <4 x i32> %b_high_2) {
; CHECK-LABEL: multiple_uses_of_carry_bit:
; CHECK:       @ %bb.0: @ %entry
; CHECK-NEXT:    .pad #8
; CHECK-NEXT:    sub sp, #8
; CHECK-NEXT:    vadci.i32 q0, q0, q2
; CHECK-NEXT:    add r0, sp, #24
; CHECK-NEXT:    vstr fpscr_nzcvqc, [sp, #4] @ 4-byte Spill
; CHECK-NEXT:    vldr fpscr_nzcvqc, [sp, #4] @ 4-byte Reload
; CHECK-NEXT:    vadc.i32 q1, q1, q3
; CHECK-NEXT:    veor q0, q0, q1
; CHECK-NEXT:    vldrw.u32 q1, [r0]
; CHECK-NEXT:    add r0, sp, #8
; CHECK-NEXT:    vldr fpscr_nzcvqc, [sp, #4] @ 4-byte Reload
; CHECK-NEXT:    vldrw.u32 q2, [r0]
; CHECK-NEXT:    vadc.i32 q1, q2, q1
; CHECK-NEXT:    veor q0, q0, q1
; CHECK-NEXT:    add sp, #8
; CHECK-NEXT:    bx lr
entry:
  %adc_low = tail call { <4 x i32>, i32 } @llvm.arm.mve.vadc.v4i32(<4 x i32> %a_low, <4 x i32> %b_low, i32 0)
  %carry = extractvalue { <4 x i32>, i32 } %adc_low, 1
  %result_low = extractvalue { <4 x i32>, i32 } %adc_low, 0
  %adc_high = tail call { <4 x i32>, i32 } @llvm.arm.mve.vadc.v4i32(<4 x i32> %a_high, <4 x i32> %b_high, i32 %carry)
  %result_high = extractvalue { <4 x i32>, i32 } %adc_high, 0
  %checksum_1 = xor <4 x i32> %result_low, %result_high
  %adc_high_2 = tail call { <4 x i32>, i32 } @llvm.arm.mve.vadc.v4i32(<4 x i32> %a_high_2, <4 x i32> %b_high_2, i32 %carry)
  %result_high_2 = extractvalue { <4 x i32>, i32 } %adc_high_2, 0
  %checksum_2 = xor <4 x i32> %checksum_1, %result_high_2
  ret <4 x i32> %checksum_2
}