This is an archive of the discontinued LLVM Phabricator instance.

[EarlyIfConversion] Add target hook to allow for multiple ifcvt iterations.
ClosedPublic

Authored by hgreving on Dec 13 2022, 5:02 PM.

Details

Summary

Adds a target hook canPredicatePredicatedInstr(const MachineInstr&) that
assumes an instruction is already predicated and returns true if it can
be predicated again, used by the early if-conversion pass in order to
iterate multiple times on architectures supporting predicate logic.

No test added since there is no upstream target that can take advantage.

Diff Detail

Event Timeline

hgreving created this revision.Dec 13 2022, 5:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2022, 5:02 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
hgreving requested review of this revision.Dec 13 2022, 5:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2022, 5:02 PM

Hi I've added reviewers from the git log. I wonder if this change is acceptable which would help us avoiding to downstream the entire pass. Thanks in advance

arsenm requested changes to this revision.Dec 14 2022, 4:08 AM
arsenm added inline comments.
llvm/lib/CodeGen/EarlyIfConversion.cpp
57

A command line flag isn’t the way to expose this. I would move this into a partner bit with isPredicable, maybe combining into a predicable kind field

This revision now requires changes to proceed.Dec 14 2022, 4:08 AM
hgreving added inline comments.Dec 14 2022, 8:32 AM
llvm/lib/CodeGen/EarlyIfConversion.cpp
57

Thanks for the comment. The reason (I agree) I just added this switch is that it is a property / tweak of the pass, and only applies to archs where a predicable instruction "is predicated". On Hexagon, a predicted instruction (AFAICS, had to dig in more) is _not_ predicable. On x86, an instruction never returns isPredicated (I guess this makes sense). ARM/AArch64 not 100% sure.

WDYT about a TII->canPredicatePredicatedIntrs() hook? Reason being this is more a property of the arch being able to support predicate logic rather than a property of each intruction.

Also problem is which architecture could I test this with :(?

jroelofs added inline comments.Dec 14 2022, 8:44 AM
llvm/lib/CodeGen/EarlyIfConversion.cpp
57

A TII hook seems appropriate. How about TII->canPredicatePredicatedInstr(*I), so the interface doesn't need to change again when a target comes along that needs to decide per-instruction.

hgreving updated this revision to Diff 482892.Dec 14 2022, 9:24 AM
hgreving retitled this revision from [EarlyIfConversion] Add switch to allow for multiple ifcvt iterations. to [EarlyIfConversion] Add target hook to allow for multiple ifcvt iterations..
hgreving edited the summary of this revision. (Show Details)
hgreving added inline comments.
llvm/lib/CodeGen/EarlyIfConversion.cpp
57

PTAL

57

PTAL

hgreving marked an inline comment as not done.Dec 14 2022, 9:27 AM
arsenm accepted this revision.Dec 14 2022, 10:17 AM
This revision is now accepted and ready to land.Dec 14 2022, 10:17 AM

Thanks for review.