[llvm] r328366 - [Hexagon] Correct update of instruction offet in HW loop fixup
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 23 13:41:45 PDT 2018
Author: kparzysz
Date: Fri Mar 23 13:41:44 2018
New Revision: 328366
URL: http://llvm.org/viewvc/llvm-project?rev=328366&view=rev
Log:
[Hexagon] Correct update of instruction offet in HW loop fixup
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonFixupHwLoops.cpp
Modified: llvm/trunk/lib/Target/Hexagon/HexagonFixupHwLoops.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonFixupHwLoops.cpp?rev=328366&r1=328365&r2=328366&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonFixupHwLoops.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonFixupHwLoops.cpp Fri Mar 23 13:41:44 2018
@@ -20,6 +20,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
+#include "llvm/Support/MathExtras.h"
#include "llvm/PassSupport.h"
using namespace llvm;
@@ -137,7 +138,7 @@ bool HexagonFixupHwLoops::fixupLoopInstr
MachineBasicBlock::iterator MII = MBB.begin();
MachineBasicBlock::iterator MIE = MBB.end();
while (MII != MIE) {
- InstOffset += HII->getSize(*MII);
+ unsigned InstSize = HII->getSize(*MII);
if (MII->isMetaInstruction()) {
++MII;
continue;
@@ -145,8 +146,10 @@ bool HexagonFixupHwLoops::fixupLoopInstr
if (isHardwareLoop(*MII)) {
assert(MII->getOperand(0).isMBB() &&
"Expect a basic block as loop operand");
- int diff = InstOffset - BlockToInstOffset[MII->getOperand(0).getMBB()];
- if ((unsigned)abs(diff) > MaxLoopRange) {
+ MachineBasicBlock *TargetBB = MII->getOperand(0).getMBB();
+ unsigned Diff = AbsoluteDifference(InstOffset,
+ BlockToInstOffset[TargetBB]);
+ if (Diff > MaxLoopRange) {
useExtLoopInstr(MF, MII);
MII = MBB.erase(MII);
Changed = true;
@@ -156,6 +159,7 @@ bool HexagonFixupHwLoops::fixupLoopInstr
} else {
++MII;
}
+ InstOffset += InstSize;
}
}
More information about the llvm-commits
mailing list