Skip to content

Commit a7697c8

Browse files
authored
[ARM] Do not assume alignment in vld1xN and vst1xN intrinsics (#106984)
These intrinsics currently assume natural alignment. Instead, respect the alignment attribute on the intrinsic. Teach InstCombine to improve that alignment. If desired I could also adjust the clang frontend to add alignment annotations equivalent to the previous behavior, but I don't see any indication that such an assumption is correct in the ARM intrinsics docs. Fixes #59081.
1 parent 77f0488 commit a7697c8

File tree

6 files changed

+256
-177
lines changed

6 files changed

+256
-177
lines changed

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21073,7 +21073,7 @@ bool ARMTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
2107321073
Info.memVT = EVT::getVectorVT(I.getType()->getContext(), MVT::i64, NumElts);
2107421074
Info.ptrVal = I.getArgOperand(I.arg_size() - 1);
2107521075
Info.offset = 0;
21076-
Info.align.reset();
21076+
Info.align = I.getParamAlign(I.arg_size() - 1).valueOrOne();
2107721077
// volatile loads with NEON intrinsics not supported
2107821078
Info.flags = MachineMemOperand::MOLoad;
2107921079
return true;
@@ -21120,7 +21120,7 @@ bool ARMTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
2112021120
Info.memVT = EVT::getVectorVT(I.getType()->getContext(), MVT::i64, NumElts);
2112121121
Info.ptrVal = I.getArgOperand(0);
2112221122
Info.offset = 0;
21123-
Info.align.reset();
21123+
Info.align = I.getParamAlign(0).valueOrOne();
2112421124
// volatile stores with NEON intrinsics not supported
2112521125
Info.flags = MachineMemOperand::MOStore;
2112621126
return true;

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ ARMTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
163163
break;
164164
}
165165

166+
case Intrinsic::arm_neon_vld1x2:
167+
case Intrinsic::arm_neon_vld1x3:
168+
case Intrinsic::arm_neon_vld1x4:
169+
case Intrinsic::arm_neon_vst1x2:
170+
case Intrinsic::arm_neon_vst1x3:
171+
case Intrinsic::arm_neon_vst1x4: {
172+
Align NewAlign =
173+
getKnownAlignment(II.getArgOperand(0), IC.getDataLayout(), &II,
174+
&IC.getAssumptionCache(), &IC.getDominatorTree());
175+
Align OldAlign = II.getParamAlign(0).valueOrOne();
176+
if (NewAlign > OldAlign)
177+
II.addParamAttr(0,
178+
Attribute::getWithAlignment(II.getContext(), NewAlign));
179+
break;
180+
}
181+
166182
case Intrinsic::arm_mve_pred_i2v: {
167183
Value *Arg = II.getArgOperand(0);
168184
Value *ArgArg;

0 commit comments

Comments
 (0)