Skip to content

Commit

Permalink
[AArch64][GlobalISel] Allow anyexting loads from 32b -> 64b to be legal.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aemerson committed Jan 8, 2024
1 parent 053aed2 commit ff47989
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
{v4s32, p0, s128, 8},
{v2s64, p0, s128, 8}})
// These extends are also legal
.legalForTypesWithMemDesc({{s32, p0, s8, 8}, {s32, p0, s16, 8}})
.legalForTypesWithMemDesc(
{{s32, p0, s8, 8}, {s32, p0, s16, 8}, {s64, p0, s32, 8}})
.widenScalarToNextPow2(0, /* MinSize = */ 8)
.lowerIfMemSizeNotByteSizePow2()
.clampScalar(0, s8, s64)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

--- |
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
entry:
ret void
}
define void @test_no_anyext(i8* %addr) {
define void @test_s32_to_s64(i8* %addr) {
entry:
ret void
}
Expand All @@ -21,28 +21,29 @@ body: |
bb.0.entry:
liveins: $x0
; CHECK-LABEL: name: test_zeroext
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8) from %ir.addr)
; CHECK: $w0 = COPY [[ZEXTLOAD]](s32)
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load (s8) from %ir.addr)
; CHECK-NEXT: $w0 = COPY [[ZEXTLOAD]](s32)
%0:_(p0) = COPY $x0
%1:_(s8) = G_LOAD %0 :: (load (s8) from %ir.addr)
%2:_(s32) = G_ZEXT %1
$w0 = COPY %2
...

---
name: test_no_anyext
name: test_s32_to_s64
legalized: true
body: |
bb.0.entry:
liveins: $x0
; Check that we don't try to do an anyext combine. We don't want to do this
; because an anyexting load like s64 = G_LOAD %p (load 4) isn't legal.
; CHECK-LABEL: name: test_no_anyext
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load (s32) from %ir.addr)
; CHECK: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[LOAD]](s32)
; CHECK: $x0 = COPY [[ANYEXT]](s64)
; CHECK-LABEL: name: test_s32_to_s64
; CHECK: liveins: $x0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK-NEXT: [[LOAD:%[0-9]+]]:_(s64) = G_LOAD [[COPY]](p0) :: (load (s32) from %ir.addr)
; CHECK-NEXT: $x0 = COPY [[LOAD]](s64)
%0:_(p0) = COPY $x0
%1:_(s32) = G_LOAD %0 :: (load (s32) from %ir.addr)
%2:_(s64) = G_ANYEXT %1
Expand Down

0 comments on commit ff47989

Please sign in to comment.