[PATCH] D100383: [LSR] Fix for pre-indexed generated constant offset
Stelios Ioannou via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 13 06:51:46 PDT 2021
stelios-arm created this revision.
stelios-arm added reviewers: SjoerdMeijer, dmgreen, sanwou01, samparker, fhahn, NickGuy.
Herald added subscribers: arphaman, hiraditya.
stelios-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Adds a check to ensure that `LSRInstance::GenerateConstantOffsetsImpl`
generates an offset that results in a legal addressing mode and formula.
Currently when building a bootstrap build with the following flags:
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} -mllvm -lsr-preferred-addressing-mode=preindexed" -DCMAKE_CXX_FLAGS="${CMAKE_C_FLAGS} -mllvm -lsr-preferred-addressing-mode=preindexed"
, it fails at compiling `TargetLoweringBase.cpp `because it generates an illegal formula.
This patch fixes this and allows to build a bootstrap build with the aforementioned flags.
https://reviews.llvm.org/D100383
Files:
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -3833,7 +3833,13 @@
for (int64_t Offset : Worklist) {
Offset -= Step;
- GenerateOffset(G, Offset);
+ Formula F = Base;
+ F.BaseOffset = (uint64_t)Base.BaseOffset - Offset;
+ // Check that the offset will result in a legal formula and addressing
+ // mode.
+ if (isLegalUse(TTI, LU.MinOffset, LU.MaxOffset, LU.Kind, LU.AccessTy,
+ F))
+ GenerateOffset(G, Offset);
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100383.337135.patch
Type: text/x-patch
Size: 737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210413/556d5517/attachment.bin>
More information about the llvm-commits
mailing list