forked from OSchip/llvm-project
[GlobalISel] Use G_ZEXTLOAD instead of an anyextending load for non-pow-2 legalization.
Fixes PR43288
This commit is contained in:
parent
2d59178634
commit
ac8a12c874
|
@ -2294,7 +2294,7 @@ LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty) {
|
||||||
// result values together, before truncating back down to the non-pow-2
|
// result values together, before truncating back down to the non-pow-2
|
||||||
// type.
|
// type.
|
||||||
// E.g. v1 = i24 load =>
|
// E.g. v1 = i24 load =>
|
||||||
// v2 = i32 load (2 byte)
|
// v2 = i32 zextload (2 byte)
|
||||||
// v3 = i32 load (1 byte)
|
// v3 = i32 load (1 byte)
|
||||||
// v4 = i32 shl v3, 16
|
// v4 = i32 shl v3, 16
|
||||||
// v5 = i32 or v4, v2
|
// v5 = i32 or v4, v2
|
||||||
|
@ -2315,8 +2315,8 @@ LegalizerHelper::lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty) {
|
||||||
LLT AnyExtTy = LLT::scalar(AnyExtSize);
|
LLT AnyExtTy = LLT::scalar(AnyExtSize);
|
||||||
Register LargeLdReg = MRI.createGenericVirtualRegister(AnyExtTy);
|
Register LargeLdReg = MRI.createGenericVirtualRegister(AnyExtTy);
|
||||||
Register SmallLdReg = MRI.createGenericVirtualRegister(AnyExtTy);
|
Register SmallLdReg = MRI.createGenericVirtualRegister(AnyExtTy);
|
||||||
auto LargeLoad =
|
auto LargeLoad = MIRBuilder.buildLoadInstr(
|
||||||
MIRBuilder.buildLoad(LargeLdReg, PtrReg, *LargeMMO);
|
TargetOpcode::G_ZEXTLOAD, LargeLdReg, PtrReg, *LargeMMO);
|
||||||
|
|
||||||
auto OffsetCst = MIRBuilder.buildConstant(
|
auto OffsetCst = MIRBuilder.buildConstant(
|
||||||
LLT::scalar(PtrTy.getSizeInBits()), LargeSplitSize / 8);
|
LLT::scalar(PtrTy.getSizeInBits()), LargeSplitSize / 8);
|
||||||
|
|
|
@ -24,19 +24,19 @@ body: |
|
||||||
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
|
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
|
||||||
; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
|
; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
|
||||||
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
|
; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
|
||||||
; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p0) :: (load 2 from %ir.ptr, align 4)
|
; CHECK: [[ZEXTLOAD:%[0-9]+]]:_(s32) = G_ZEXTLOAD [[COPY]](p0) :: (load 2 from %ir.ptr, align 4)
|
||||||
; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
|
; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
|
||||||
; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C1]](s64)
|
; CHECK: [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C1]](s64)
|
||||||
; CHECK: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[GEP]](p0) :: (load 1 from %ir.ptr + 2, align 4)
|
; CHECK: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p0) :: (load 1 from %ir.ptr + 2, align 4)
|
||||||
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
|
; CHECK: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
|
||||||
; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[LOAD1]], [[C2]](s32)
|
; CHECK: [[SHL:%[0-9]+]]:_(s32) = G_SHL [[LOAD]], [[C2]](s32)
|
||||||
; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[SHL]], [[LOAD]]
|
; CHECK: [[OR:%[0-9]+]]:_(s32) = G_OR [[SHL]], [[ZEXTLOAD]]
|
||||||
; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[OR]](s32)
|
; CHECK: [[COPY2:%[0-9]+]]:_(s32) = COPY [[OR]](s32)
|
||||||
; CHECK: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
|
; CHECK: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 16
|
||||||
; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY2]], [[C3]](s64)
|
; CHECK: [[LSHR:%[0-9]+]]:_(s32) = G_LSHR [[COPY2]], [[C3]](s64)
|
||||||
; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY1]], [[C1]](s64)
|
; CHECK: [[PTR_ADD1:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY1]], [[C1]](s64)
|
||||||
; CHECK: G_STORE [[COPY2]](s32), [[COPY1]](p0) :: (store 2 into %ir.ptr2, align 4)
|
; CHECK: G_STORE [[COPY2]](s32), [[COPY1]](p0) :: (store 2 into %ir.ptr2, align 4)
|
||||||
; CHECK: G_STORE [[LSHR]](s32), [[GEP1]](p0) :: (store 1 into %ir.ptr2 + 2, align 4)
|
; CHECK: G_STORE [[LSHR]](s32), [[PTR_ADD1]](p0) :: (store 1 into %ir.ptr2 + 2, align 4)
|
||||||
; CHECK: $w0 = COPY [[C]](s32)
|
; CHECK: $w0 = COPY [[C]](s32)
|
||||||
; CHECK: RET_ReallyLR implicit $w0
|
; CHECK: RET_ReallyLR implicit $w0
|
||||||
%0:_(p0) = COPY $x0
|
%0:_(p0) = COPY $x0
|
||||||
|
|
Loading…
Reference in New Issue