Page MenuHomePhabricator

[PowerPC][NFC] Do not enter prefix selection if it cannot do better.

Authored by stefanp on Mar 17 2021, 9:40 AM.



Do not try to materialize a constant using prefix instructions if the selection
using non prefix instructions was able to do it using a single non prefix

Diff Detail

Event Timeline

stefanp created this revision.Mar 17 2021, 9:40 AM
stefanp requested review of this revision.Mar 17 2021, 9:40 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2021, 9:40 AM
stefanp added reviewers: lei, Restricted Project.Mar 17 2021, 9:41 AM
NeHuang added inline comments.

Please correct me if I my understand is wrong here. It seems to me InstCntDirect=1 case has been covered in the check below.

 // If the prefix and non-prefix cases use the same number of instructions
// we will prefer the non-prefix case.
    if (ResultP && (!Result || InstCntDirectP < InstCntDirect))

Then intention of adding an early exit for InstCntDirect == 1 case is to save the trial of calling selectI64ImmDirectPrefix and further checks below.

amyk added a subscriber: amyk.Mar 19 2021, 3:06 PM
amyk added inline comments.

nit: Spelling.

nemanjai accepted this revision.Mar 19 2021, 7:37 PM



I think you should simplify this comment to something like:

// If we have prefixed instructions and there is a chance we can
// materialize the constant with fewer prefixed instructions than
// non-prefixed, try that.

This clearly communicates that there is no point doing any further checks if we can materialize this with just a single non-prefixed instruction (i.e. we won't be able to materialize it with zero instructions).

This revision is now accepted and ready to land.Mar 19 2021, 7:37 PM
stefanp updated this revision to Diff 332278.Mar 22 2021, 7:13 AM

Updated comment.

stefanp added inline comments.Mar 22 2021, 7:15 AM

Yes that is correct. There is no need to call selectI64ImmDirectPrefix if we already know that it will fail the check InstCntDirectP < InstCntDirect and that the result it produces won't be used.

This revision was landed with ongoing or failed builds.Mar 22 2021, 7:18 AM
This revision was automatically updated to reflect the committed changes.
NeHuang added inline comments.Mar 22 2021, 7:18 AM

Thanks. LGTM.