Skip to content

Commit ff47989

Browse files
committed
[AArch64][GlobalISel] Allow anyexting loads from 32b -> 64b to be legal.
We can already support selection of these through imported patterns, we were just missing the legalizer rule to allow these to be formed. Nano size benefit overall.
1 parent 053aed2 commit ff47989

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
366366
{v4s32, p0, s128, 8},
367367
{v2s64, p0, s128, 8}})
368368
// These extends are also legal
369-
.legalForTypesWithMemDesc({{s32, p0, s8, 8}, {s32, p0, s16, 8}})
369+
.legalForTypesWithMemDesc(
370+
{{s32, p0, s8, 8}, {s32, p0, s16, 8}, {s64, p0, s32, 8}})
370371
.widenScalarToNextPow2(0, /* MinSize = */ 8)
371372
.lowerIfMemSizeNotByteSizePow2()
372373
.clampScalar(0, s8, s64)

llvm/test/CodeGen/AArch64/GlobalISel/combine-ext-debugloc.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Check that when we combine ZEXT/ANYEXT we assign the correct location.
44
# CHECK: !8 = !DILocation(line: 23, column: 5, scope: !4)
5-
# CHECK: G_AND %15, %16, debug-location !8
5+
# CHECK: G_AND %14, %15, debug-location !8
66

77
--- |
88
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"

llvm/test/CodeGen/AArch64/GlobalISel/postlegalizercombiner-extending-loads.mir

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
entry:
99
ret void
1010
}
11-
define void @test_no_anyext(i8* %addr) {
11+
define void @test_s32_to_s64(i8* %addr) {
1212
entry:
1313
ret void
1414
}
@@ -21,28 +21,29 @@ body: |
2121
bb.0.entry:
2222
liveins: $x0
2323
; CHECK-LABEL: name: test_zeroext
24-
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
25-
; CHECK: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8) from %ir.addr)
26-
; CHECK: $w0 = COPY [[ZEXTLOAD]](s32)
24+
; CHECK: liveins: $x0
25+
; CHECK-NEXT: {{ $}}
26+
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
27+
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8) from %ir.addr)
28+
; CHECK-NEXT: $w0 = COPY [[ZEXTLOAD]](s32)
2729
%0:_(p0) = COPY $x0
2830
%1:_(s8) = G_LOAD %0 :: (load (s8) from %ir.addr)
2931
%2:_(s32) = G_ZEXT %1
3032
$w0 = COPY %2
3133
...
3234

3335
---
34-
name: test_no_anyext
36+
name: test_s32_to_s64
3537
legalized: true
3638
body: |
3739
bb.0.entry:
3840
liveins: $x0
39-
; Check that we don't try to do an anyext combine. We don't want to do this
40-
; because an anyexting load like s64 = G_LOAD %p (load 4) isn't legal.
41-
; CHECK-LABEL: name: test_no_anyext
42-
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
43-
; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load (s32) from %ir.addr)
44-
; CHECK: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[LOAD]](s32)
45-
; CHECK: $x0 = COPY [[ANYEXT]](s64)
41+
; CHECK-LABEL: name: test_s32_to_s64
42+
; CHECK: liveins: $x0
43+
; CHECK-NEXT: {{ $}}
44+
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
45+
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s64) = G_LOAD [[COPY]](p0) :: (load (s32) from %ir.addr)
46+
; CHECK-NEXT: $x0 = COPY [[LOAD]](s64)
4647
%0:_(p0) = COPY $x0
4748
%1:_(s32) = G_LOAD %0 :: (load (s32) from %ir.addr)
4849
%2:_(s64) = G_ANYEXT %1

0 commit comments

Comments
 (0)