Skip to content

Commit da78214

Browse files
[AArch64][NFC] Add test for vector udiv scalarization
1 parent d748c81 commit da78214

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s
3+
4+
; This test verifies that udiv by constant works correctly even when type
5+
; legalization promotes constant operands (e.g., i16 -> i32 in BUILD_VECTOR).
6+
; This is a regression test for a bug where v16i16 would be split into two
7+
; v8i16 operations during legalization, the i16 constants would be promoted
8+
; to i32, and then the second DAGCombine round would fail to recognize the
9+
; promoted constants when trying to convert udiv into mul+shift.
10+
11+
define <8 x i16> @udiv_v8i16_by_255(<8 x i16> %x) {
12+
; CHECK-LABEL: udiv_v8i16_by_255:
13+
; CHECK: // %bb.0:
14+
; CHECK-NEXT: mov w8, #32897 // =0x8081
15+
; CHECK-NEXT: dup v1.8h, w8
16+
; CHECK-NEXT: umull2 v2.4s, v0.8h, v1.8h
17+
; CHECK-NEXT: umull v0.4s, v0.4h, v1.4h
18+
; CHECK-NEXT: uzp2 v0.8h, v0.8h, v2.8h
19+
; CHECK-NEXT: ushr v0.8h, v0.8h, #7
20+
; CHECK-NEXT: ret
21+
%div = udiv <8 x i16> %x, splat (i16 255)
22+
ret <8 x i16> %div
23+
}
24+
25+
define <16 x i16> @udiv_v16i16_by_255(<16 x i16> %x) {
26+
; CHECK-LABEL: udiv_v16i16_by_255:
27+
; CHECK: // %bb.0:
28+
; CHECK-NEXT: umov w9, v0.h[0]
29+
; CHECK-NEXT: umov w11, v1.h[0]
30+
; CHECK-NEXT: mov w8, #258 // =0x102
31+
; CHECK-NEXT: movk w8, #257, lsl #16
32+
; CHECK-NEXT: umov w10, v0.h[1]
33+
; CHECK-NEXT: umov w12, v1.h[1]
34+
; CHECK-NEXT: umov w13, v0.h[2]
35+
; CHECK-NEXT: umov w14, v1.h[2]
36+
; CHECK-NEXT: umull x9, w9, w8
37+
; CHECK-NEXT: umull x11, w11, w8
38+
; CHECK-NEXT: umull x10, w10, w8
39+
; CHECK-NEXT: umull x12, w12, w8
40+
; CHECK-NEXT: lsr x9, x9, #32
41+
; CHECK-NEXT: lsr x11, x11, #32
42+
; CHECK-NEXT: umull x13, w13, w8
43+
; CHECK-NEXT: fmov s2, w9
44+
; CHECK-NEXT: lsr x10, x10, #32
45+
; CHECK-NEXT: umov w9, v0.h[3]
46+
; CHECK-NEXT: fmov s3, w11
47+
; CHECK-NEXT: lsr x12, x12, #32
48+
; CHECK-NEXT: umull x11, w14, w8
49+
; CHECK-NEXT: umov w14, v1.h[3]
50+
; CHECK-NEXT: mov v2.h[1], w10
51+
; CHECK-NEXT: lsr x10, x13, #32
52+
; CHECK-NEXT: mov v3.h[1], w12
53+
; CHECK-NEXT: umov w12, v0.h[4]
54+
; CHECK-NEXT: lsr x11, x11, #32
55+
; CHECK-NEXT: umull x9, w9, w8
56+
; CHECK-NEXT: umull x13, w14, w8
57+
; CHECK-NEXT: umov w14, v1.h[4]
58+
; CHECK-NEXT: mov v2.h[2], w10
59+
; CHECK-NEXT: mov v3.h[2], w11
60+
; CHECK-NEXT: lsr x9, x9, #32
61+
; CHECK-NEXT: umull x10, w12, w8
62+
; CHECK-NEXT: lsr x12, x13, #32
63+
; CHECK-NEXT: umov w11, v0.h[5]
64+
; CHECK-NEXT: umull x13, w14, w8
65+
; CHECK-NEXT: umov w14, v1.h[5]
66+
; CHECK-NEXT: mov v2.h[3], w9
67+
; CHECK-NEXT: lsr x9, x10, #32
68+
; CHECK-NEXT: mov v3.h[3], w12
69+
; CHECK-NEXT: lsr x12, x13, #32
70+
; CHECK-NEXT: umull x10, w11, w8
71+
; CHECK-NEXT: umov w11, v0.h[6]
72+
; CHECK-NEXT: umull x13, w14, w8
73+
; CHECK-NEXT: umov w14, v1.h[6]
74+
; CHECK-NEXT: mov v2.h[4], w9
75+
; CHECK-NEXT: umov w9, v0.h[7]
76+
; CHECK-NEXT: mov v3.h[4], w12
77+
; CHECK-NEXT: lsr x10, x10, #32
78+
; CHECK-NEXT: lsr x12, x13, #32
79+
; CHECK-NEXT: umull x11, w11, w8
80+
; CHECK-NEXT: umull x13, w14, w8
81+
; CHECK-NEXT: umov w14, v1.h[7]
82+
; CHECK-NEXT: mov v2.h[5], w10
83+
; CHECK-NEXT: umull x9, w9, w8
84+
; CHECK-NEXT: mov v3.h[5], w12
85+
; CHECK-NEXT: lsr x10, x11, #32
86+
; CHECK-NEXT: lsr x11, x13, #32
87+
; CHECK-NEXT: umull x8, w14, w8
88+
; CHECK-NEXT: lsr x9, x9, #32
89+
; CHECK-NEXT: mov v2.h[6], w10
90+
; CHECK-NEXT: mov v3.h[6], w11
91+
; CHECK-NEXT: lsr x8, x8, #32
92+
; CHECK-NEXT: mov v2.h[7], w9
93+
; CHECK-NEXT: mov v3.h[7], w8
94+
; CHECK-NEXT: mov v0.16b, v2.16b
95+
; CHECK-NEXT: mov v1.16b, v3.16b
96+
; CHECK-NEXT: ret
97+
%div = udiv <16 x i16> %x, splat (i16 255)
98+
ret <16 x i16> %div
99+
}

0 commit comments

Comments
 (0)