[llvm] r341851 - [Hexagon] Split large offsets into properly aligned addends

Krzysztof Parzyszek via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 10 11:49:16 PDT 2018


Author: kparzysz
Date: Mon Sep 10 11:49:16 2018
New Revision: 341851

URL: http://llvm.org/viewvc/llvm-project?rev=341851&view=rev
Log:
[Hexagon] Split large offsets into properly aligned addends

Modified:
    llvm/trunk/lib/Target/Hexagon/HexagonConstExtenders.cpp

Modified: llvm/trunk/lib/Target/Hexagon/HexagonConstExtenders.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonConstExtenders.cpp?rev=341851&r1=341850&r2=341851&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonConstExtenders.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonConstExtenders.cpp Mon Sep 10 11:49:16 2018
@@ -1708,6 +1708,15 @@ bool HCE::replaceInstrExpr(const ExtDesc
 
     // 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))




More information about the llvm-commits mailing list