Skip to content

Commit aab2256

Browse files
committed
[VP] Provide createAlignedLoad to emit VP load instruction.
1 parent 08decd2 commit aab2256

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

llvm/include/llvm/IR/VectorBuilder.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ class VectorBuilder {
106106
Value *createSimpleTargetReduction(Intrinsic::ID RdxID, Type *ValTy,
107107
ArrayRef<Value *> VecOpArray,
108108
const Twine &Name = Twine());
109+
110+
/// Emit a VP load intrinsic call.
111+
/// \param Ty The return type of the load.
112+
/// \param Ptr The load address.
113+
/// \param Alignment The alignment information of the load.
114+
CallInst *createAlignedLoad(Type *Ty, Value *Ptr, Align Alignment,
115+
const Twine &Name = Twine());
109116
};
110117

111118
} // namespace llvm

llvm/lib/IR/VectorBuilder.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ Value *VectorBuilder::createSimpleTargetReduction(Intrinsic::ID RdxID,
7070
return createVectorInstructionImpl(VPID, ValTy, InstOpArray, Name);
7171
}
7272

73+
CallInst *VectorBuilder::createAlignedLoad(Type *Ty, Value *Ptr,
74+
Align Alignment, const Twine &Name) {
75+
auto VPLI =
76+
cast<CallInst>(createVectorInstruction(Instruction::Load, Ty, Ptr, Name));
77+
VPLI->addParamAttr(
78+
0, Attribute::getWithAlignment(VPLI->getContext(), Alignment));
79+
return VPLI;
80+
}
81+
7382
Value *VectorBuilder::createVectorInstructionImpl(Intrinsic::ID VPID,
7483
Type *ReturnTy,
7584
ArrayRef<Value *> InstOpArray,

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9364,11 +9364,8 @@ void VPWidenLoadEVLRecipe::execute(VPTransformState &State) {
93649364
} else {
93659365
VectorBuilder VBuilder(Builder);
93669366
VBuilder.setEVL(EVL).setMask(Mask);
9367-
NewLI = cast<CallInst>(VBuilder.createVectorInstruction(
9368-
Instruction::Load, DataTy, Addr, "vp.op.load"));
9367+
NewLI = VBuilder.createAlignedLoad(DataTy, Addr, Alignment, "vp.op.load");
93699368
}
9370-
NewLI->addParamAttr(
9371-
0, Attribute::getWithAlignment(NewLI->getContext(), Alignment));
93729369
State.addMetadata(NewLI, LI);
93739370
Instruction *Res = NewLI;
93749371
if (isReverse())

0 commit comments

Comments
 (0)