1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

[GlobalISel] Fix sext_inreg(load) combine to not move the originating load.

The builder was using the extend user as the insertion point, which meant that
we were incorrectly "moving" the load from its original position, and therefore
could violate memory operation ordering.
This commit is contained in:
Amara Emerson 2021-02-11 19:14:41 -08:00
parent abb3df8ce4
commit b519f0f5db
2 changed files with 29 additions and 1 deletions

View File

@ -730,7 +730,7 @@ bool CombinerHelper::applySextInRegOfLoad(
// %ld = G_SEXTLOAD %ptr (load 1)
auto &MMO = **LoadDef->memoperands_begin();
Builder.setInstrAndDebugLoc(MI);
Builder.setInstrAndDebugLoc(*LoadDef);
auto &MF = Builder.getMF();
auto PtrInfo = MMO.getPointerInfo();
auto *NewMMO = MF.getMachineMemOperand(&MMO, PtrInfo, ScalarSizeBits / 8);

View File

@ -24,6 +24,34 @@ body: |
$w0 = COPY %3(s32)
RET_ReallyLR implicit $w0
...
---
name: sextload_from_inreg_across_store
alignment: 4
tracksRegLiveness: true
liveins:
- { reg: '$x0' }
body: |
bb.1:
liveins: $x0
; Check that the extend gets folded into the load, not the other way around, which
; could cause mem dependence violations.
; CHECK-LABEL: name: sextload_from_inreg_across_store
; CHECK: liveins: $x0
; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
; CHECK: [[SEXTLOAD:%[0-9]+]]:_(s16) = G_SEXTLOAD [[COPY]](p0) :: (load 1, align 2)
; CHECK: G_STORE [[COPY]](p0), [[COPY]](p0) :: (store 8)
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[SEXTLOAD]](s16)
; CHECK: $w0 = COPY [[ANYEXT]](s32)
; CHECK: RET_ReallyLR implicit $w0
%0:_(p0) = COPY $x0
%1:_(s16) = G_LOAD %0(p0) :: (load 2)
G_STORE %0(p0), %0(p0) :: (store 8)
%2:_(s16) = G_SEXT_INREG %1, 8
%3:_(s32) = G_ANYEXT %2(s16)
$w0 = COPY %3(s32)
RET_ReallyLR implicit $w0
...
---
name: non_pow_2_inreg