summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
index 81bb36135d8..efbf6fe9c36 100644
--- a/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
@@ -1708,6 +1708,15 @@ bool HCE::replaceInstrExpr(const ExtDesc &ED, const ExtenderInit &ExtI,
// Clamp Diff to the 16 bit range.
int32_t D = isInt<16>(Diff) ? Diff : (Diff > 0 ? 32767 : -32768);
+ if (Diff > 32767) {
+ // Split Diff into two values: one that is close to min/max int16,
+ // and the other being the rest, and such that both have the same
+ // "alignment" as Diff.
+ uint32_t UD = Diff;
+ OffsetRange R = getOffsetRange(MI.getOperand(0));
+ uint32_t A = std::min<uint32_t>(R.Align, 1u << countTrailingZeros(UD));
+ D &= ~(A-1);
+ }
BuildMI(MBB, At, dl, HII->get(IdxOpc))
.add(MI.getOperand(0))
.add(MachineOperand(ExtR))
OpenPOWER on IntegriCloud