This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Fix incorrect `isLegalAddressingMode`
ClosedPublic

Authored by chill on Feb 13 2023, 2:48 AM.

Details

Summary

AArch64TargetLowering::isLegalAddressingMode has a number of defects, including
accepting an addressing mode, which consists of only an immediate operand, or not checking
the offset range for an addressing mode in the form 1*ScaledReg + Offs.

This patch fixes the above issues.

Diff Detail

Event Timeline

chill created this revision.Feb 13 2023, 2:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2023, 2:48 AM
chill requested review of this revision.Feb 13 2023, 2:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 13 2023, 2:48 AM
chill edited the summary of this revision. (Show Details)Feb 13 2023, 6:37 AM
chill updated this revision to Diff 503839.Mar 9 2023, 10:30 AM
chill updated this revision to Diff 508535.Mar 27 2023, 2:16 AM

Fixed a few places in LSR where we called isLegalAddressingMode without a base register, even
though we meant an addressing mode with a base register.

chill updated this revision to Diff 509368.Mar 29 2023, 7:44 AM

+ canonicalise 2*Reg into Reg + Reg

I can certainly imagine that we haven't got Addressing modes without a BaseReg entirely correct in the past and just assumed it was present. The change in IsSimplerBaseSCEVForTarget I added recently and look more correct now.

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3185

Can you give more details why this is changed to HasBaseReg? It seems that isAlwaysFoldable already sets ScaledReg to 1 or -1, so this now tests for BaseReg + 1/-1*ScaledReg + IncOffset?

chill added inline comments.Apr 19 2023, 7:12 AM
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
3185

Right, it's incorrect.
However, I'd rather see if I can fix it by changing isAlwaysFoldable, that invents a scale existence without any external input.

To be continued ...

chill updated this revision to Diff 515006.Apr 19 2023, 10:04 AM
chill marked an inline comment as done.
dmgreen accepted this revision.Apr 20 2023, 5:53 AM

Thanks. LGTM

This revision is now accepted and ready to land.Apr 20 2023, 5:53 AM
This revision was landed with ongoing or failed builds.Apr 20 2023, 7:45 AM
This revision was automatically updated to reflect the committed changes.
chill reopened this revision.Apr 20 2023, 8:11 AM
This revision is now accepted and ready to land.Apr 20 2023, 8:11 AM
chill planned changes to this revision.Apr 20 2023, 8:11 AM
chill updated this revision to Diff 515716.Apr 21 2023, 6:39 AM

Work around TargetLowering::AddrMode no longer an aggregate in C++20.

This revision is now accepted and ready to land.Apr 21 2023, 6:39 AM
chill requested review of this revision.Apr 21 2023, 7:18 AM
dmgreen accepted this revision.Apr 21 2023, 7:25 AM

LGTM still.

This revision is now accepted and ready to land.Apr 21 2023, 7:25 AM
This revision was landed with ongoing or failed builds.Apr 21 2023, 8:21 AM
This revision was automatically updated to reflect the committed changes.