This is an archive of the discontinued LLVM Phabricator instance.

[X86] Use GFNI for vXi8 shifts/rotates
Changes PlannedPublic

Authored by RKSimon on Oct 29 2022, 1:25 PM.

Details

Reviewers
pengfei
FreddyYe
Summary

As detailed here: https://github.com/InstLatx64/InstLatX64_Demo/blob/master/GFNI_Demo.h

We can use the gf2p8affine instruction to lower byte shifts/rotates as well as the existing bitreverse case.

I've added a concat(gf2p8affine, gf2p8affine) to remerge AVX1 splitting - but TBH, I'm not certain if there's ever going to be a AVX1+GFNI target, but that might be just one of the things we handle like the weird combinations of AVX512 modes....

There's a few other GFNI patterns we can probably handle - e.g. TZCNT/LZCNT were detailed on PR47394

Diff Detail

Event Timeline

RKSimon created this revision.Oct 29 2022, 1:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 29 2022, 1:25 PM
RKSimon requested review of this revision.Oct 29 2022, 1:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 29 2022, 1:25 PM
pengfei added inline comments.Oct 30 2022, 11:56 PM
llvm/lib/Target/X86/X86ISelLowering.cpp
29935

Amt > 0 && Amt < 8?

RKSimon planned changes to this revision.Nov 1 2022, 3:47 AM
Matt added a subscriber: Matt.Nov 1 2022, 5:54 PM
RKSimon updated this revision to Diff 474942.Nov 12 2022, 6:12 AM
RKSimon edited the summary of this revision. (Show Details)

Ensure the shift/rotation amounts are in range, which allows us to simplify the mask generation

pengfei added inline comments.Nov 12 2022, 7:26 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
30193

ditto.

31062

Do we need to check it here? Can we simply use isTypeLegal(VT)?

31065

Use NumElts / 8 like below.

BTW, do we need to update the TTI table for them?

RKSimon planned changes to this revision.Dec 6 2022, 2:06 PM