Skip to content

Commit 0663710

Browse files
authored
[X86] narrowBitOpRMW/combineTruncate - don't retain pointer info for unknown offset load/stores (#166752)
#166337 replaces large (illegal type) loads/stores with a smaller i32 load/store based off the demanded shifted bits. As these shifts are non-constant we can't regenerate the PointerInfo data with a fixed offset, so we need to discard the data entirely. Fixes #166744 - post-ra has to reconstruct dependencies after the chains have been stripped and uses pointer info instead - which resulted in some loads being rescheduled earlier than the dependent store as it was thought they didn't alias
1 parent e4467fb commit 0663710

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53442,7 +53442,8 @@ static SDValue narrowBitOpRMW(StoreSDNode *St, const SDLoc &DL,
5344253442
}
5344353443

5344453444
SDValue NewStore =
53445-
DAG.getStore(St->getChain(), DL, Res, NewPtr, St->getPointerInfo(),
53445+
DAG.getStore(St->getChain(), DL, Res, NewPtr,
53446+
MachinePointerInfo(St->getPointerInfo().getAddrSpace()),
5344653447
Align(), St->getMemOperand()->getFlags());
5344753448

5344853449
// If there are other uses of StoredVal, replace with a new load of the
@@ -54639,7 +54640,8 @@ static SDValue combineTruncate(SDNode *N, SelectionDAG &DAG,
5463954640
SDValue NewPtr = DAG.getMemBasePlusOffset(
5464054641
Ld->getBasePtr(), PtrByteOfs, DL, SDNodeFlags::NoUnsignedWrap);
5464154642
SDValue NewLoad =
54642-
DAG.getLoad(VT, DL, Ld->getChain(), NewPtr, Ld->getPointerInfo(),
54643+
DAG.getLoad(VT, DL, Ld->getChain(), NewPtr,
54644+
MachinePointerInfo(Ld->getPointerInfo().getAddrSpace()),
5464354645
Align(), Ld->getMemOperand()->getFlags());
5464454646
DAG.makeEquivalentMemoryOrdering(Ld, NewLoad);
5464554647
return NewLoad;

llvm/test/CodeGen/X86/pr166744.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; RUN: llc < %s -mtriple=x86_64-- -mcpu=haswell | FileCheck %s --check-prefixes=NOPOSTRA
44
; RUN: llc < %s -mtriple=x86_64-- -mcpu=x86-64-v3 | FileCheck %s --check-prefixes=NOPOSTRA
55

6-
; FIXME: Ensure reloads are after narrowed i512 -> i32 store
6+
; Ensure reloads are after narrowed i512 -> i32 store
77
define i1 @PR166744(ptr %v, i64 %idx, i1 zeroext %b) {
88
; POSTRA-LABEL: PR166744:
99
; POSTRA: # %bb.0:
@@ -12,15 +12,15 @@ define i1 @PR166744(ptr %v, i64 %idx, i1 zeroext %b) {
1212
; POSTRA-NEXT: bextrl %eax, %esi, %eax
1313
; POSTRA-NEXT: movl (%rdi,%rax,4), %ecx
1414
; POSTRA-NEXT: btrl %esi, %ecx
15-
; POSTRA-NEXT: movq 8(%rdi), %rsi
16-
; POSTRA-NEXT: orq 40(%rdi), %rsi
1715
; POSTRA-NEXT: orl %ecx, %edx
1816
; POSTRA-NEXT: movl %edx, (%rdi,%rax,4)
1917
; POSTRA-NEXT: movq 16(%rdi), %rax
18+
; POSTRA-NEXT: movq (%rdi), %rcx
2019
; POSTRA-NEXT: movq 24(%rdi), %rdx
20+
; POSTRA-NEXT: movq 8(%rdi), %rsi
2121
; POSTRA-NEXT: orq 56(%rdi), %rdx
22+
; POSTRA-NEXT: orq 40(%rdi), %rsi
2223
; POSTRA-NEXT: orq 48(%rdi), %rax
23-
; POSTRA-NEXT: movq (%rdi), %rcx
2424
; POSTRA-NEXT: orq 32(%rdi), %rcx
2525
; POSTRA-NEXT: orq %rdx, %rsi
2626
; POSTRA-NEXT: orq %rax, %rcx

0 commit comments

Comments
 (0)