[llvm] dd50e26 - [NFC][IR] Remove unused assignment to Offset
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 30 05:15:59 PST 2022
Author: Alfonso Gregory
Date: 2022-12-30T08:01:50-05:00
New Revision: dd50e26f8a844aa7dc9908b94bce66188c4d4e91
URL: https://github.com/llvm/llvm-project/commit/dd50e26f8a844aa7dc9908b94bce66188c4d4e91
DIFF: https://github.com/llvm/llvm-project/commit/dd50e26f8a844aa7dc9908b94bce66188c4d4e91.diff
LOG: [NFC][IR] Remove unused assignment to Offset
This value is overwritten anyway, so let's remove it
Added:
Modified:
llvm/lib/IR/Operator.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Operator.cpp b/llvm/lib/IR/Operator.cpp
index 0e263118d885b..4e400adbb9ac2 100644
--- a/llvm/lib/IR/Operator.cpp
+++ b/llvm/lib/IR/Operator.cpp
@@ -63,7 +63,7 @@ Align GEPOperator::getMaxPreservedAlignment(const DataLayout &DL) const {
Align Result = Align(llvm::Value::MaximumAlignment);
for (gep_type_iterator GTI = gep_type_begin(this), GTE = gep_type_end(this);
GTI != GTE; ++GTI) {
- int64_t Offset = 1;
+ uint64_t Offset;
ConstantInt *OpC = dyn_cast<ConstantInt>(GTI.getOperand());
if (StructType *STy = GTI.getStructTypeOrNull()) {
@@ -71,11 +71,9 @@ Align GEPOperator::getMaxPreservedAlignment(const DataLayout &DL) const {
Offset = SL->getElementOffset(OpC->getZExtValue());
} else {
assert(GTI.isSequential() && "should be sequencial");
- /// If the index isn't know we take 1 because it is the index that will
+ /// If the index isn't known, we take 1 because it is the index that will
/// give the worse alignment of the offset.
- int64_t ElemCount = 1;
- if (OpC)
- ElemCount = OpC->getZExtValue();
+ const uint64_t ElemCount = OpC ? OpC->getZExtValue() : 1;
Offset = DL.getTypeAllocSize(GTI.getIndexedType()) * ElemCount;
}
Result = Align(MinAlign(Offset, Result.value()));
More information about the llvm-commits
mailing list