This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Fold (X & Y) != 0 --> zextOrTrunc(X & Y) iff everything but LSB is known zero (PR51312)
ClosedPublic

Authored by RKSimon on Jan 23 2022, 6:23 AM.

Details

Summary

Fixes parity codegen issue where we know all but the lowest bit is zero, we can replace the ICMPNE with 0 comparison with a zext/trunc

Diff Detail

Event Timeline

RKSimon created this revision.Jan 23 2022, 6:23 AM
RKSimon requested review of this revision.Jan 23 2022, 6:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 23 2022, 6:23 AM

I think you are missing

if (TLI.getBooleanContents(VT) == TargetLowering::UndefinedBooleanContent ||
    TLI.getBooleanContents(VT) == TargetLowering::ZeroOrOneBooleanContent)

I think you are missing

if (TLI.getBooleanContents(VT) == TargetLowering::UndefinedBooleanContent ||
    TLI.getBooleanContents(VT) == TargetLowering::ZeroOrOneBooleanContent)

Nice catch!

RKSimon updated this revision to Diff 402321.Jan 23 2022, 7:28 AM

address feedback

lebedev.ri accepted this revision.Jan 23 2022, 7:45 AM

LG, thanks.

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
3273–3274

?

This revision is now accepted and ready to land.Jan 23 2022, 7:45 AM
RKSimon added inline comments.Jan 23 2022, 8:02 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
3273–3274

SGTM - cheers

This revision was landed with ongoing or failed builds.Jan 23 2022, 8:20 AM
This revision was automatically updated to reflect the committed changes.