This is an archive of the discontinued LLVM Phabricator instance.

[ARM][SchedModels] Convert IsLdrAm3RegOffPred to MCSchedPredicate
ClosedPublic

Authored by evgeny777 on Oct 21 2020, 5:54 AM.

Diff Detail

Event Timeline

evgeny777 created this revision.Oct 21 2020, 5:54 AM
evgeny777 requested review of this revision.Oct 21 2020, 5:54 AM

Hi Eugene,

could you please upload a diff with the full context?

Do you know why isAddrMode3OpMinusReg and isAddrMode3OpImm are not declared as static members of ARMBaseInstrInfo?
It seems to me that those should be static. I am asking this question because there may be better ways to implement this patch without having to touch the predicate expander.
Most of the checks performed by those predicates are just checking if operands are registers or specific immediate values. We already have specialised predicates for describing constraints on register operands and immediate operands. I would personally use CheckFunctionPredicate only as a last resort, if there is no other way to express the same predicate.

evgeny777 updated this revision to Diff 299700.Oct 21 2020, 8:14 AM
evgeny777 retitled this revision from [ARM][SchedModels] Convert few cortex-a57 predicates to MCSchedPredicate to [ARM][SchedModels] Convert IsLdrAm3RegOffPred to MCSchedPredicate.

@andreadb Makes sense. Let's try AArch64-like approach for this case. I've updated patch to handle just IsLdrAm3RegOffPred

andreadb added inline comments.Oct 21 2020, 9:30 AM
llvm/lib/Target/ARM/ARMScheduleA57.td
31–34

It seems to me that the original intent of isAddrMode3OpImm is to check if an operand is NOT the invalid register.

isAddrMode3OpImm also seems to require that the operand must be a register (otherwise the getReg() would have trigger an assertion failure - since isReg() would have returned false).

CheckIsRegOperand(idx) is simply testing if the operand at index idx is a register. However, it doesn't check the actual value of that register.

You should be able to use CheckInvalidRegOperand.
Basically, the original implementation is equivalent to:
CheckNot<CheckInvalidRegOperand<index>>.

That being said, in the original code, the return value from isAddrMode3OpImm is also negated (example):

!TII->isAddrMode3OpImm(*MI, 1)

Assuming that my understanding of the code is correct, I guess that you should be able to just use a simple CheckInvalidRegOperand in your case.

evgeny777 added inline comments.Oct 21 2020, 9:35 AM
llvm/lib/Target/ARM/ARMScheduleA57.td
31–34

There is not operator in the original code {!TII->isAddrMode3OpImm(*MI, 1)} which I forgot about :(. I'll update the diff shortly

Addressed

Thanks!

I cannot comment on the mca numbers (I leave that part of the review to @dmgreen).
The changes to the predicates look good to me.


As a side note (unrelated to this patch):
If in future you plan to rewrite isAddrMode3OpMinusReg, then I suggest you to have a look at TIIPredicate.
Note also that CheckImmOperand_s can be used to define predicates like this:

MyFunction(MI->getOperand(Index).getImm()) == Val

(see for example the code comments for CheckOperandBase in TargetInstrPredicate.td).

dmgreen accepted this revision.Oct 21 2020, 10:34 AM

Change LGTM. Thanks

This revision is now accepted and ready to land.Oct 21 2020, 10:34 AM