This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Correctly reduce BV to shuffle with zero on big endian
ClosedPublic

Authored by nemanjai on Mar 20 2023, 3:04 PM.

Details

Summary

This DAG combine is correct on little endian targets but is incorrect on big endian targets. Add big endian code to correct it.

Diff Detail

Event Timeline

nemanjai created this revision.Mar 20 2023, 3:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2023, 3:04 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
nemanjai requested review of this revision.Mar 20 2023, 3:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2023, 3:04 PM
Herald added a subscriber: wdng. · View Herald Transcript
RKSimon accepted this revision.Mar 21 2023, 3:09 AM
RKSimon added a subscriber: RKSimon.

LGTM with one very optional minor

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
22013

(very pedantic) Maybe worth pulling out this:

unsigned Low = DAG.getDataLayout().isBigEndian() ? (ZextRatio - 1) : 0;
ShufMask[i] = ((i % ZextRatio) == Low) ? Extract.getConstantOperandVal(1) : NumMaskElts;
This revision is now accepted and ready to land.Mar 21 2023, 3:09 AM
nemanjai added inline comments.Mar 24 2023, 7:19 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
22013

I don't mind getting rid of the tiny if/else statements. Thanks. I'll update it.