This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] merge scaled and unscaled zero narrow stores.
ClosedPublic

Authored by zjaffal on May 19 2023, 7:26 AM.

Details

Summary

This patch fixes a crash when a sclaed and unscaled zero stores are merged.

Diff Detail

Event Timeline

zjaffal created this revision.May 19 2023, 7:26 AM
zjaffal requested review of this revision.May 19 2023, 7:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2023, 7:26 AM
t.p.northover added inline comments.May 19 2023, 7:53 AM
llvm/test/CodeGen/AArch64/str-narrow-zero-merge.ll
11 ↗(On Diff #523763)

I think the patch needs more work. This offset is clearly not right (it's in the caller's frame).

zjaffal updated this revision to Diff 524806.May 23 2023, 11:06 AM
  1. Change the way offsets are calculated to handle mixing of scaled and unscaled stores.
  2. Change the test to use .mir instead of .ll
fhahn added inline comments.May 24 2023, 1:10 AM
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
765

Instead we could just assign OffsetStrideRtMI in the if above (like RtMI) using the already computed strides?

768

There's no need to check for IsScaled here, as we will just multiply with 1 in the unscaled case

zjaffal updated this revision to Diff 525073.May 24 2023, 2:10 AM
  1. Assign OffsetImm to the appropriate value without doing recalculations.
  2. Remove unecessary checks.
fhahn added a comment.May 24 2023, 7:50 AM

Could you make sure that we have tests where the first offset is > the second offset and with negative offsets?

llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
760

nit: This doesn't calculate the final offset, only selects the offset

766

the code below doesn't adjust the final offset any longer?

zjaffal updated this revision to Diff 525547.May 25 2023, 4:52 AM

Fix comments

fhahn accepted this revision.May 25 2023, 5:50 AM
fhahn added reviewers: efriedma, dmgreen.

LGTM, thanks! Would be good to wait with committing a day or so in case there are additional comments.

This revision is now accepted and ready to land.May 25 2023, 5:50 AM
This revision was landed with ongoing or failed builds.May 26 2023, 7:07 AM
This revision was automatically updated to reflect the committed changes.