[PATCH] D54653: [IRBuilder] Remove positivity check from CreateAlignmentAssumption()
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 24 11:00:29 PST 2019
lebedev.ri updated this revision to Diff 183341.
lebedev.ri retitled this revision from " Remove branch from CreateAlignmentAssumption" to "[IRBuilder] Remove positivity check from CreateAlignmentAssumption()".
lebedev.ri edited the summary of this revision.
lebedev.ri added a reviewer: rjmccall.
lebedev.ri set the repository for this revision to rL LLVM.
lebedev.ri added a comment.
Took over as discussed, rewrote from scratch based on previous disscussions/review feedback.
@hfinkel et al - please formally accept if this makes sense.
Repository:
rL LLVM
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
@@ -2279,10 +2279,11 @@
Value **TheCheck = 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, TheCheck);
}
@@ -2309,15 +2310,10 @@
Type *IntPtrTy = getIntPtrTy(DL, PtrTy->getAddressSpace());
if (Alignment->getType() != IntPtrTy)
- Alignment = CreateIntCast(Alignment, IntPtrTy, /*isSigned*/ true,
+ Alignment = CreateIntCast(Alignment, IntPtrTy, /*isSigned*/ false,
"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, TheCheck);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54653.183341.patch
Type: text/x-patch
Size: 1803 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190124/c40574ec/attachment.bin>
More information about the llvm-commits
mailing list