Skip to content

Commit 40f6599

Browse files
committed
[AArch64][GlobalISel] Make G_SADDE and G_SSUBE legal
This makes G_SADDE and G_SSUBE legal in preparation for further work legalizing overflowing operations. It's fine that they don't have an instruction selector implementation yet, because G_UADDE and G_USUBE are already legal on AArch64 without an instruction selector implementation. This completes the set of G_[SU]{ADD,SUB}[EO] operations on AArch64. Reviewed By: paquette Differential Revision: https://reviews.llvm.org/D95325
1 parent 79c7273 commit 40f6599

File tree

4 files changed

+59
-5
lines changed

4 files changed

+59
-5
lines changed

llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
166166
getActionDefinitionsBuilder({G_SMULH, G_UMULH}).legalFor({s32, s64});
167167

168168
getActionDefinitionsBuilder(
169-
{G_UADDE, G_USUBE, G_SADDO, G_SSUBO, G_UADDO, G_USUBO})
169+
{G_SADDE, G_SSUBE, G_UADDE, G_USUBE, G_SADDO, G_SSUBO, G_UADDO, G_USUBO})
170170
.legalFor({{s32, s1}, {s64, s1}})
171171
.minScalar(0, s32);
172172

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
# RUN: llc -mtriple aarch64 -verify-machineinstrs -run-pass=legalizer -debugify-and-strip-all-safe %s -o - | FileCheck %s
3+
4+
---
5+
name: test_scalar_sadde_32
6+
body: |
7+
bb.0.entry:
8+
; CHECK-LABEL: name: test_scalar_sadde_32
9+
; CHECK: %lhs:_(s32) = COPY $w0
10+
; CHECK: %rhs:_(s32) = COPY $w1
11+
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w2
12+
; CHECK: %carry_in:_(s1) = G_TRUNC [[COPY]](s32)
13+
; CHECK: %add:_(s32), %carry_out:_(s1) = G_SADDE %lhs, %rhs, %carry_in
14+
; CHECK: %carry_out_ext:_(s32) = G_ANYEXT %carry_out(s1)
15+
; CHECK: $w0 = COPY %add(s32)
16+
; CHECK: $w1 = COPY %carry_out_ext(s32)
17+
%lhs:_(s32) = COPY $w0
18+
%rhs:_(s32) = COPY $w1
19+
%2:_(s32) = COPY $w2
20+
%carry_in:_(s1) = G_TRUNC %2
21+
%add:_(s32), %carry_out:_(s1) = G_SADDE %lhs, %rhs, %carry_in
22+
%carry_out_ext:_(s32) = G_ANYEXT %carry_out
23+
$w0 = COPY %add
24+
$w1 = COPY %carry_out_ext
25+
26+
...
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
# RUN: llc -mtriple aarch64 -verify-machineinstrs -run-pass=legalizer -debugify-and-strip-all-safe %s -o - | FileCheck %s
3+
4+
---
5+
name: test_scalar_ssube_32
6+
body: |
7+
bb.0.entry:
8+
; CHECK-LABEL: name: test_scalar_ssube_32
9+
; CHECK: %lhs:_(s32) = COPY $w0
10+
; CHECK: %rhs:_(s32) = COPY $w1
11+
; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w2
12+
; CHECK: %carry_in:_(s1) = G_TRUNC [[COPY]](s32)
13+
; CHECK: %sub:_(s32), %carry_out:_(s1) = G_SSUBE %lhs, %rhs, %carry_in
14+
; CHECK: %carry_out_ext:_(s32) = G_ANYEXT %carry_out(s1)
15+
; CHECK: $w0 = COPY %sub(s32)
16+
; CHECK: $w1 = COPY %carry_out_ext(s32)
17+
%lhs:_(s32) = COPY $w0
18+
%rhs:_(s32) = COPY $w1
19+
%2:_(s32) = COPY $w2
20+
%carry_in:_(s1) = G_TRUNC %2
21+
%sub:_(s32), %carry_out:_(s1) = G_SSUBE %lhs, %rhs, %carry_in
22+
%carry_out_ext:_(s32) = G_ANYEXT %carry_out
23+
$w0 = COPY %sub
24+
$w1 = COPY %carry_out_ext
25+
26+
...

llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@
297297
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
298298
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
299299
# DEBUG-NEXT: G_UADDE (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
300+
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
300301
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
301302
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
302303
# DEBUG-NEXT: G_USUBO (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
@@ -312,15 +313,16 @@
312313
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
313314
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
314315
# DEBUG-NEXT: G_SADDE (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
315-
# DEBUG-NEXT: .. type index coverage check SKIPPED: no rules defined
316-
# DEBUG-NEXT: .. imm index coverage check SKIPPED: no rules defined
316+
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
317+
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
317318
# DEBUG-NEXT: G_SSUBO (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
318319
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
319320
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
320321
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
321322
# DEBUG-NEXT: G_SSUBE (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
322-
# DEBUG-NEXT: .. type index coverage check SKIPPED: no rules defined
323-
# DEBUG-NEXT: .. imm index coverage check SKIPPED: no rules defined
323+
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
324+
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
325+
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
324326
# DEBUG-NEXT: G_UMULO (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
325327
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
326328
# DEBUG-NEXT: .. the first uncovered type index: 2, OK

0 commit comments

Comments
 (0)