[PATCH] D54653: Remove branch from CreateAlignmentAssumption
Erich Keane via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 4 10:18:04 PST 2018
erichkeane updated this revision to Diff 176670.
erichkeane retitled this revision from "Correct CreateAlignmentAssumption to check sign and power-of-2 (LLVM Part)" to " Remove branch from CreateAlignmentAssumption".
erichkeane edited the summary of this revision.
erichkeane added a comment.
As Hal suggested, revert the change to check for positivity at all.
Only test affected is in Clang, so I'll fix that as a part of submitting this.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54653/new/
https://reviews.llvm.org/D54653
Files:
include/llvm/IR/IRBuilder.h
Index: include/llvm/IR/IRBuilder.h
===================================================================
--- include/llvm/IR/IRBuilder.h
+++ include/llvm/IR/IRBuilder.h
@@ -2164,10 +2164,11 @@
Value *OffsetValue = nullptr) {
assert(isa<PointerType>(PtrValue->getType()) &&
"trying to create an alignment assumption on a non-pointer?");
+ assert(Alignment != 0 && "Invalid Alignment");
auto *PtrTy = cast<PointerType>(PtrValue->getType());
Type *IntPtrTy = getIntPtrTy(DL, PtrTy->getAddressSpace());
- Value *Mask = ConstantInt::get(IntPtrTy, Alignment > 0 ? Alignment - 1 : 0);
+ Value *Mask = ConstantInt::get(IntPtrTy, Alignment - 1);
return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
OffsetValue);
}
@@ -2192,13 +2193,7 @@
if (Alignment->getType() != IntPtrTy)
Alignment = CreateIntCast(Alignment, IntPtrTy, /*isSigned*/ true,
"alignmentcast");
- Value *IsPositive =
- CreateICmp(CmpInst::ICMP_SGT, Alignment,
- ConstantInt::get(Alignment->getType(), 0), "ispositive");
- Value *PositiveMask =
- CreateSub(Alignment, ConstantInt::get(IntPtrTy, 1), "positivemask");
- Value *Mask = CreateSelect(IsPositive, PositiveMask,
- ConstantInt::get(IntPtrTy, 0), "mask");
+ Value *Mask = CreateSub(Alignment, ConstantInt::get(IntPtrTy, 1), "mask");
return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
OffsetValue);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54653.176670.patch
Type: text/x-patch
Size: 1641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181204/31bd4be9/attachment.bin>
More information about the llvm-commits
mailing list