Skip to content

Commit 2876b3e

Browse files
committed
[SelectionDAG] Always preserve offset in MachinePointerInfo
Previously, getWithOffset() would drop the offset if the base was null. Because of this, MachineMemOperand would return the wrong result from getAlign() in these cases. MachineMemOperand stores the alignment of the pointer without the offset. A bunch of MIR tests changed because we print the offset now. Split off from D77687. Differential Revision: https://reviews.llvm.org/D78049
1 parent 5ea2819 commit 2876b3e

18 files changed

+6637
-6637
lines changed

llvm/include/llvm/CodeGen/MachineMemOperand.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ struct MachinePointerInfo {
5858
AddrSpace = v ? v->getAddressSpace() : 0;
5959
}
6060

61-
explicit MachinePointerInfo(unsigned AddressSpace = 0)
62-
: V((const Value *)nullptr), Offset(0), StackID(0),
61+
explicit MachinePointerInfo(unsigned AddressSpace = 0, int64_t offset = 0)
62+
: V((const Value *)nullptr), Offset(offset), StackID(0),
6363
AddrSpace(AddressSpace) {}
6464

6565
explicit MachinePointerInfo(
@@ -77,10 +77,10 @@ struct MachinePointerInfo {
7777

7878
MachinePointerInfo getWithOffset(int64_t O) const {
7979
if (V.isNull())
80-
return MachinePointerInfo(AddrSpace);
80+
return MachinePointerInfo(AddrSpace, Offset + O);
8181
if (V.is<const Value*>())
82-
return MachinePointerInfo(V.get<const Value*>(), Offset+O, StackID);
83-
return MachinePointerInfo(V.get<const PseudoSourceValue*>(), Offset+O,
82+
return MachinePointerInfo(V.get<const Value*>(), Offset + O, StackID);
83+
return MachinePointerInfo(V.get<const PseudoSourceValue*>(), Offset + O,
8484
StackID);
8585
}
8686

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-load-constant-32bit.mir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ body: |
1414
; CI: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[MV]](p4) :: (load 1, addrspace 6)
1515
; CI: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
1616
; CI: [[PTR_ADD:%[0-9]+]]:_(p4) = G_PTR_ADD [[MV]], [[C1]](s64)
17-
; CI: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p4) :: (load 1, addrspace 6)
17+
; CI: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p4) :: (load 1 + 1, addrspace 6)
1818
; CI: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
1919
; CI: [[PTR_ADD1:%[0-9]+]]:_(p4) = G_PTR_ADD [[MV]], [[C2]](s64)
20-
; CI: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p4) :: (load 1, addrspace 6)
20+
; CI: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p4) :: (load 1 + 2, addrspace 6)
2121
; CI: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 3
2222
; CI: [[PTR_ADD2:%[0-9]+]]:_(p4) = G_PTR_ADD [[MV]], [[C3]](s64)
23-
; CI: [[LOAD3:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD2]](p4) :: (load 1, addrspace 6)
23+
; CI: [[LOAD3:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD2]](p4) :: (load 1 + 3, addrspace 6)
2424
; CI: [[C4:%[0-9]+]]:_(s16) = G_CONSTANT i16 255
2525
; CI: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[LOAD]](s32)
2626
; CI: [[AND:%[0-9]+]]:_(s16) = G_AND [[TRUNC]], [[C4]]

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-load-constant.mir

Lines changed: 1160 additions & 1160 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-load-flat.mir

Lines changed: 1015 additions & 1015 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-load-global.mir

Lines changed: 951 additions & 951 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-load-local.mir

Lines changed: 1178 additions & 1178 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-load-private.mir

Lines changed: 1212 additions & 1212 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-sextload-constant-32bit.mir

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ body: |
3232
; CI: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[MV]](p4) :: (load 2, addrspace 6)
3333
; CI: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
3434
; CI: [[PTR_ADD:%[0-9]+]]:_(p4) = G_PTR_ADD [[MV]], [[C1]](s64)
35-
; CI: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p4) :: (load 2, addrspace 6)
35+
; CI: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p4) :: (load 2 + 2, addrspace 6)
3636
; CI: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
3737
; CI: [[COPY1:%[0-9]+]]:_(s32) = COPY [[LOAD]](s32)
3838
; CI: [[AND:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C2]]
@@ -61,13 +61,13 @@ body: |
6161
; CI: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[MV]](p4) :: (load 1, addrspace 6)
6262
; CI: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
6363
; CI: [[PTR_ADD:%[0-9]+]]:_(p4) = G_PTR_ADD [[MV]], [[C1]](s64)
64-
; CI: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p4) :: (load 1, addrspace 6)
64+
; CI: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p4) :: (load 1 + 1, addrspace 6)
6565
; CI: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 2
6666
; CI: [[PTR_ADD1:%[0-9]+]]:_(p4) = G_PTR_ADD [[MV]], [[C2]](s64)
67-
; CI: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p4) :: (load 1, addrspace 6)
67+
; CI: [[LOAD2:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD1]](p4) :: (load 1 + 2, addrspace 6)
6868
; CI: [[C3:%[0-9]+]]:_(s64) = G_CONSTANT i64 3
6969
; CI: [[PTR_ADD2:%[0-9]+]]:_(p4) = G_PTR_ADD [[MV]], [[C3]](s64)
70-
; CI: [[LOAD3:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD2]](p4) :: (load 1, addrspace 6)
70+
; CI: [[LOAD3:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD2]](p4) :: (load 1 + 3, addrspace 6)
7171
; CI: [[C4:%[0-9]+]]:_(s16) = G_CONSTANT i16 255
7272
; CI: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[LOAD]](s32)
7373
; CI: [[AND:%[0-9]+]]:_(s16) = G_AND [[TRUNC]], [[C4]]
@@ -149,7 +149,7 @@ body: |
149149
; CI: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[MV]](p4) :: (load 1, addrspace 6)
150150
; CI: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
151151
; CI: [[PTR_ADD:%[0-9]+]]:_(p4) = G_PTR_ADD [[MV]], [[C1]](s64)
152-
; CI: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p4) :: (load 1, addrspace 6)
152+
; CI: [[LOAD1:%[0-9]+]]:_(s32) = G_LOAD [[PTR_ADD]](p4) :: (load 1 + 1, addrspace 6)
153153
; CI: [[C2:%[0-9]+]]:_(s16) = G_CONSTANT i16 255
154154
; CI: [[TRUNC:%[0-9]+]]:_(s16) = G_TRUNC [[LOAD]](s32)
155155
; CI: [[AND:%[0-9]+]]:_(s16) = G_AND [[TRUNC]], [[C2]]

0 commit comments

Comments
 (0)