This is an archive of the discontinued LLVM Phabricator instance.

[X86] Attempt to match multiple binary reduction ops at once. NFCI
ClosedPublic

Authored by RKSimon on Nov 7 2017, 4:00 AM.

Details

Summary

matchBinOpReduction currently matches against a single opcode, but we already have a case where we try to match against AND/OR and I'll be shortly adding another case for SMAX/SMIN/UMAX/UMIN.

This NFCI patch alters matchBinOpReduction to try and pattern match against any of the provided list of candidate bin ops at once to save time.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Nov 7 2017, 4:00 AM
andreadb accepted this revision.Nov 9 2017, 5:28 AM

LGTM.

I made a couple of (minor) comments below.

lib/Target/X86/X86ISelLowering.cpp
30119–30126 ↗(On Diff #121869)

If you want, you can move this check outside of the loop. The value of CandidateBinOp is only set by the first iteration of the loop, based on node Op.
If you decide to move the check before the loop, then the check for Op.getOpcode() != CandidateBinOp can be moved at around line 30140 (i.e. after the block of code that sets the Op for the next stage).

30138–30141 ↗(On Diff #121869)

That comment seems to imply that we always try to match an 'add' reduction. I suggest to change the comment so that it says 'binary operation' instead of 'add'.

This revision is now accepted and ready to land.Nov 9 2017, 5:28 AM

Thanks Andrea

lib/Target/X86/X86ISelLowering.cpp
30119–30126 ↗(On Diff #121869)

If you decide to move the check before the loop, then the check for Op.getOpcode() != CandidateBinOp can be moved at around line 30140 (i.e. after the block of code that sets the Op for the next stage).

This bit I'm not going to do as Op doesn't have to match BinOp on the last loop - its's easier to leave the existing test at the start of the loop.

This revision was automatically updated to reflect the committed changes.