[llvm] e00cfe2 - [Local] Simplify the alignment limits in getOrEnforceKnownAlignment. NFCI
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 18 12:53:05 PDT 2020
Author: Craig Topper
Date: 2020-04-18T12:52:47-07:00
New Revision: e00cfe254d99629ec344031adfe1878a84f3b0b3
URL: https://github.com/llvm/llvm-project/commit/e00cfe254d99629ec344031adfe1878a84f3b0b3
DIFF: https://github.com/llvm/llvm-project/commit/e00cfe254d99629ec344031adfe1878a84f3b0b3.diff
LOG: [Local] Simplify the alignment limits in getOrEnforceKnownAlignment. NFCI
We previously clamped the trailing zero count to 31 bits. And
then clamped the final alignment to MaximumAlignment which is
1 << 29.
This patch simplifies this to just clamp the trailing zero to
29 using MaxAlignmentExponent.
I was looking into changing this function to use Align/MaybeAlign
and noticed this.
Differential Revision: https://reviews.llvm.org/D78418
Added:
Modified:
llvm/lib/Transforms/Utils/Local.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index b9dff8c02ce4..b013b4681087 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1215,13 +1215,11 @@ unsigned llvm::getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign,
// Avoid trouble with ridiculously large TrailZ values, such as
// those computed from a null pointer.
- TrailZ = std::min(TrailZ, unsigned(sizeof(unsigned) * CHAR_BIT - 1));
+ // LLVM doesn't support alignments larger than (1 << MaxAlignmentExponent).
+ TrailZ = std::min(TrailZ, Value::MaxAlignmentExponent);
unsigned Align = 1u << std::min(Known.getBitWidth() - 1, TrailZ);
- // LLVM doesn't support alignments larger than this currently.
- Align = std::min(Align, +Value::MaximumAlignment);
-
if (PrefAlign > Align)
Align = enforceKnownAlignment(V, Align, PrefAlign, DL);
More information about the llvm-commits
mailing list