[PATCH] D143271: [NFC] Simplify logic in ConstantFold
Guillaume Chatelet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 3 07:41:17 PST 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c80d24a4b24: [NFC] Simplify logic in ConstantFold (authored by gchatelet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143271/new/
https://reviews.llvm.org/D143271
Files:
llvm/lib/IR/ConstantFold.cpp
Index: llvm/lib/IR/ConstantFold.cpp
===================================================================
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -1053,7 +1053,7 @@
isa<GlobalValue>(CE1->getOperand(0))) {
GlobalValue *GV = cast<GlobalValue>(CE1->getOperand(0));
- MaybeAlign GVAlign;
+ Align GVAlign; // defaults to 1
if (Module *TheModule = GV->getParent()) {
const DataLayout &DL = TheModule->getDataLayout();
@@ -1073,14 +1073,14 @@
} else if (isa<Function>(GV)) {
// Without a datalayout we have to assume the worst case: that the
// function pointer isn't aligned at all.
- GVAlign = std::nullopt;
+ GVAlign = Align(1);
} else if (isa<GlobalVariable>(GV)) {
- GVAlign = cast<GlobalVariable>(GV)->getAlign();
+ GVAlign = cast<GlobalVariable>(GV)->getAlign().valueOrOne();
}
- if (GVAlign && *GVAlign > 1) {
+ if (GVAlign > 1) {
unsigned DstWidth = CI2->getType()->getBitWidth();
- unsigned SrcWidth = std::min(DstWidth, Log2(*GVAlign));
+ unsigned SrcWidth = std::min(DstWidth, Log2(GVAlign));
APInt BitsNotSet(APInt::getLowBitsSet(DstWidth, SrcWidth));
// If checking bits we know are clear, return zero.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143271.494637.patch
Type: text/x-patch
Size: 1393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230203/b1caa065/attachment.bin>
More information about the llvm-commits
mailing list