This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add some missing dependency-breaking zero idiom patterns to scheduler models
ClosedPublic

Authored by RKSimon on Jan 17 2022, 8:38 AM.

Details

Summary

Many of the x86 scheduler models are not accounting for their microarch's ability to handle dependency-breaking zero idioms (pxor xmm0,xmm0 etc.), which is causing some notable differences when comparing llvm-mca reports to iaca, uops.info etc.

These are based on the Intel AoMs and Agner's docs which list the instructions handled on each cpu model - there may be more, although tbh the xor/pxor/xorps/xorpd are by far the most commonly encountered.

Once this is in place we also need to review missing support for 'allones' idioms and reg-reg move elimination, but this needs fixing first.

@lebedev.ri The Barcelona test changes are due to the cpu still being tagged as using the SandyBridge model, if/when you get back to D63628 these will need to be addressed.

Based on an original patch by @andreadb (Andrea Di Biagio)

Diff Detail

Event Timeline

RKSimon created this revision.Jan 17 2022, 8:38 AM
RKSimon requested review of this revision.Jan 17 2022, 8:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 17 2022, 8:38 AM
pengfei added inline comments.Jan 17 2022, 6:15 PM
llvm/lib/Target/X86/X86SchedBroadwell.td
1762

I didn't find this information on AoM.

llvm/test/tools/llvm-mca/X86/Znver1/zero-idioms.s
205–206

I know nothing about znver, but is 0 too aggressive?

RKSimon added inline comments.Jan 18 2022, 2:42 AM
llvm/lib/Target/X86/X86SchedBroadwell.td
1762

Yes - the PCMPGT variants are only mentioned in Agner's microarch doc, not in the Intel AoM - should I drop them?

llvm/test/tools/llvm-mca/X86/Znver1/zero-idioms.s
205–206

This is a general llvm-mca behaviour - it assumes that there is no need for physical reg allocation for known zero registers - its nothing to do with znver specifically (all the test cases here are zeroidioms so it reports zero).

pengfei accepted this revision.Jan 18 2022, 5:52 AM

LGTM, but let's see if other reviewers have opinion about it.

llvm/lib/Target/X86/X86SchedBroadwell.td
1762

I don't have strong opinion about that. I assume Agner's information is reasonable. So I'm happy with it.

llvm/test/tools/llvm-mca/X86/Znver1/zero-idioms.s
205–206

Got it, thank you.

This revision is now accepted and ready to land.Jan 18 2022, 5:52 AM
andreadb accepted this revision.Jan 19 2022, 2:42 AM

LGTM too.

This revision was landed with ongoing or failed builds.Jan 19 2022, 3:30 AM
This revision was automatically updated to reflect the committed changes.