This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Fold xor/and/or (bitcast(A), bitcast(B)) -> bitcast(op (A,B)) anytime before LegalizeVectorOprs
ClosedPublic

Authored by RKSimon on Apr 10 2016, 8:19 AM.

Details

Summary

xor/and/or (bitcast(A), bitcast(B)) -> bitcast(op (A,B)) was only being combined at the AfterLegalizeTypes stage, this patch permits the combine to occur anytime before then as well.

My aim with this to improve the ability to recognise bitmasks that can be coverted to shuffles.

Elena - I had to modify a number of AVX512 mask tests as the basic bitcast to/from scalar pattern was being stripped out preventing testing of the mmask bitops. By replacing the bitcasts with loads I can get almost the same result.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 53179.Apr 10 2016, 8:19 AM
RKSimon retitled this revision from to [DAGCombiner] Fold xor/and/or (bitcast(A), bitcast(B)) -> bitcast(op (A,B)) anytime before LegalizeVectorOprs.
RKSimon updated this object.
RKSimon added reviewers: qcolombet, delena, spatel, andreadb.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
delena added inline comments.Apr 10 2016, 10:31 AM
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
2776 ↗(On Diff #53179)

I'm not sure that it is safe for illegal types. You don't cover this in the tests.
If you want to do the transformation before type promotion, you, probably, should check that the types are legal.

test/CodeGen/X86/avx512-mask-op.ll
95 ↗(On Diff #53179)

What code will be generated on the original test?
I'd prefer do not change the existing tests.

RKSimon updated this revision to Diff 53216.Apr 11 2016, 4:24 AM

Thanks Elena,

I've split the AVX512 mask tests - the old tests now perform the operations on the scalar unit (as that was what the masks have been bitcasted from), but the new memory tests perform the operations on the mask unit.

I've also added a number of widening/legalization tests to demonstrate the effect of permitting the combine to work on pre-legalized types.

delena accepted this revision.Apr 11 2016, 5:13 AM
delena edited edge metadata.

Thank you.

This revision is now accepted and ready to land.Apr 11 2016, 5:13 AM
This revision was automatically updated to reflect the committed changes.