[llvm] r328360 - [Hexagon] Assume all extendable branches to be of size 8 in relaxation
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 23 12:47:13 PDT 2018
Author: kparzysz
Date: Fri Mar 23 12:47:13 2018
New Revision: 328360
URL: http://llvm.org/viewvc/llvm-project?rev=328360&view=rev
Log:
[Hexagon] Assume all extendable branches to be of size 8 in relaxation
The branch relaxation pass collects sizes of all instructions at the
beginning, before any changes have been made. It then performs one pass
over all branches to see which ones need to be extended. It does not
account for the case when a previously valid branch becomes out-of-range
due to relaxing other branches.
This approach fixes this problem by assuming from the beginning that
all extendable branches have been extended. This may cause unneeded
relaxation in some cases, but avoids iteration and recomputing instruction
sizes.
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonBranchRelaxation.cpp
Modified: llvm/trunk/lib/Target/Hexagon/HexagonBranchRelaxation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonBranchRelaxation.cpp?rev=328360&r1=328359&r2=328360&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonBranchRelaxation.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonBranchRelaxation.cpp Fri Mar 23 12:47:13 2018
@@ -114,8 +114,12 @@ void HexagonBranchRelaxation::computeOff
InstOffset = (InstOffset + ByteAlign) & ~(ByteAlign);
}
OffsetMap[&B] = InstOffset;
- for (auto &MI : B.instrs())
+ for (auto &MI : B.instrs()) {
InstOffset += HII->getSize(MI);
+ // Assume that all extendable branches will be extended.
+ if (MI.isBranch() && HII->isExtendable(MI))
+ InstOffset += HEXAGON_INSTR_SIZE;
+ }
}
}
@@ -145,6 +149,9 @@ bool HexagonBranchRelaxation::isJumpOutO
if (FirstTerm == B.instr_end())
return false;
+ if (HII->isExtended(MI))
+ return false;
+
unsigned InstOffset = BlockToInstOffset[&B];
unsigned Distance = 0;
More information about the llvm-commits
mailing list