Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/Scalar/InferAlignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ static bool tryToImproveAlign(
cast<ConstantInt>(II->getArgOperand(AlignOpIdx))->getAlignValue();
Align PrefAlign = DL.getPrefTypeAlign(Type);
Align NewAlign = Fn(PtrOp, OldAlign, PrefAlign);
if (NewAlign <= OldAlign)
if (NewAlign <= OldAlign ||
NewAlign.value() > std::numeric_limits<uint32_t>().max())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Value::MaxAlignmentExponent / MaximumAlignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured this was more straightforward since the problem is that Align is stored as i64 but this argument is i32, so this makes it clear that it's a size issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arsenm We already use MaxAlignmentExponent -- the problem is that these specific intrinsics don't support the full alignment range (the maximum exponent is one less).

return false;

Value *V =
Expand Down
12 changes: 12 additions & 0 deletions llvm/test/Transforms/InferAlignment/masked.ll
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ entry:
ret void
}

define <2 x i32> @null(<2 x i1> %mask, <2 x i32> %val) {
; CHECK-LABEL: define <2 x i32> @null(
; CHECK-SAME: <2 x i1> [[MASK:%.*]], <2 x i32> [[VAL:%.*]]) {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[MASKED_LOAD:%.*]] = tail call <2 x i32> @llvm.masked.load.v2i32.p0(ptr null, i32 1, <2 x i1> [[MASK]], <2 x i32> [[VAL]])
; CHECK-NEXT: ret <2 x i32> [[MASKED_LOAD]]
;
entry:
%masked_load = tail call <2 x i32> @llvm.masked.load.v2f64.p0(ptr null, i32 1, <2 x i1> %mask, <2 x i32> %val)
ret <2 x i32> %masked_load
}

declare void @llvm.assume(i1)
declare <2 x i32> @llvm.masked.load.v2i32.p0(ptr, i32, <2 x i1>, <2 x i32>)
declare void @llvm.masked.store.v2i32.p0(<2 x i32>, ptr, i32, <2 x i1>)