This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine][PowerPC] Simplify nabs by using legal `smin` operation
ClosedPublic

Authored by lkail on Dec 4 2020, 12:04 AM.

Details

Summary

Convert 0 - abs(x) to smin (x, -x) if smin is a legal operation.

Verification: https://alive2.llvm.org/ce/z/vpquFR

Diff Detail

Event Timeline

lkail created this revision.Dec 4 2020, 12:04 AM
lkail requested review of this revision.Dec 4 2020, 12:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2020, 12:04 AM
RKSimon added inline comments.Dec 4 2020, 2:00 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
3216

We might be able to adapt TargetLowering::expandABS with a Negate bool to handle this - we're doing some very similar expansions there already.

lkail updated this revision to Diff 309838.Dec 7 2020, 1:59 AM

Per @RKSimon 's suggestion.

RKSimon accepted this revision.Dec 7 2020, 2:04 AM

LGTM - cheers

This revision is now accepted and ready to land.Dec 7 2020, 2:04 AM
This revision was landed with ongoing or failed builds.Dec 7 2020, 7:24 PM
This revision was automatically updated to reflect the committed changes.