This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Replace `performANDSCombine` with `performFlagSettingCombine`.
ClosedPublic

Authored by Kmeakin on Apr 26 2022, 9:54 AM.

Details

Summary

performFlagSettingCombine is a generalised version of performANDSCombine which also works on ADDS, SUBS, ADCS and SBCS

Diff Detail

Event Timeline

Kmeakin created this revision.Apr 26 2022, 9:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2022, 9:54 AM
Kmeakin requested review of this revision.Apr 26 2022, 9:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2022, 9:54 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
17706

Should this be {N->ops()} to support the ADC case? Is it possible to write tests for the new opcode cases?

18723–18726

Do the ADDS and SUBS cases occur today? If they do then can we have some tests.

Kmeakin marked 2 inline comments as done.May 9 2022, 9:59 AM
Kmeakin added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
17706

I did try thi

17706

I couldn't find a way to construct an ArrayRef<SDValue> that would live long enough: the ArrayRef would get dropped at the end of the function while the Generic node still held a reference to its contents, leading to a segfault later. Suggest to leave it as is for now.

18723–18726

Could not generate any tests where these transforms would fire, but its worth leaving these in for completeness: they might become applicable later if new transforms add the opportunity for them to apply.

paulwalker-arm added inline comments.May 11 2022, 3:01 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
18723–18726

I disagree. Although the code is likely fine if there's no way to test it then it's just stale, potentially buggy code that bloats the compiler.

18785–18786

Is there a good reason to move this code?

Kmeakin marked 3 inline comments as done.May 11 2022, 11:05 AM
Kmeakin added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
18785–18786

To group it with other calls to performFlagSettingCombine

Kmeakin updated this revision to Diff 428729.May 11 2022, 11:34 AM
Kmeakin marked an inline comment as done.

Remove ADDS and SUBS cases, since I could not find any test cases where they fire.

paulwalker-arm accepted this revision.May 12 2022, 3:13 AM
paulwalker-arm added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
18785–18786

That's not a great reason, especially since it's no longer true. But it's minor so I'll not worry about it.

This revision is now accepted and ready to land.May 12 2022, 3:13 AM
This revision was landed with ongoing or failed builds.May 12 2022, 2:17 PM
This revision was automatically updated to reflect the committed changes.