aboutsummaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/X86/X86ISelDAGToDAG.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp
index f4a9ca38d2..6bef55c2b0 100644
--- a/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -608,11 +608,14 @@ bool X86DAGToDAGISel::FoldOffsetIntoAddress(uint64_t Offset,
!isDispSafeForFrameIndex(Val))
return true;
// LOCALMOD-BEGIN
- // Do not allow negative displacements to be folded into memory operations.
- // This results in trying to dereference a negative offset from RZP
+ // Do not fold large offsets into displacements.
+ // Various constant folding and address-mode selections can result in
+ // 32-bit operations (e.g. from GEP) getting folded into the displacement
+ // and often results in a negative value in the index register
+ // (see also LegalizeAddressModeForNaCl)
else if (Subtarget->isTargetNaCl64() &&
- AM.BaseType == X86ISelAddressMode::RegBase && Val < 0 &&
- selectingMemOp)
+ AM.BaseType == X86ISelAddressMode::RegBase &&
+ (Val > 65535 || Val < -65536) && selectingMemOp)
return true;
// LOCALMOD-END
}