summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
index 5b72fea34ca..40e11451ede 100644
--- a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
@@ -1040,10 +1040,13 @@ OffsetRange HCE::getOffsetRange(Register Rb, const MachineInstr &MI) const {
unsigned L = Log2_32(A);
unsigned S = 10+L; // sint11_L
int32_t Min = -alignDown((1<<S)-1, A);
- int32_t Max = 0; // Force non-negative offsets.
- OffsetRange R = { Min, Max, A };
+ // The range will be shifted by Off. To prefer non-negative offsets,
+ // adjust Max accordingly.
int32_t Off = MI.getOperand(OffP).getImm();
+ int32_t Max = Off >= 0 ? 0 : -Off;
+
+ OffsetRange R = { Min, Max, A };
return R.shift(Off);
}
@@ -1622,6 +1625,9 @@ bool HCE::replaceInstrExpr(const ExtDesc &ED, const ExtenderInit &ExtI,
#ifndef NDEBUG
// Make sure the output is within allowable range for uses.
OffsetRange Uses = getOffsetRange(MI.getOperand(0));
+ if (!Uses.contains(Diff))
+ dbgs() << "Diff: " << Diff << " out of range " << Uses
+ << " for " << MI;
assert(Uses.contains(Diff));
#endif
MBB.erase(MI);
OpenPOWER on IntegriCloud