This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner][X86] Teach DAGCombiner to fold (not (neg X)) -> (add X, -1)
ClosedPublic

Authored by craig.topper on Jun 3 2019, 3:41 PM.

Details

Summary

This is a special case of a more general transform (not (sub Y, X)) -> (add X, ~Y). InstCombine knows the general form. I've restricted to the special case to fix the motivating case PR42118. I tried handling any case where Y was constant, but got some changes on some Mips tests that I couldn't quickly prove where beneficial.

Fixes PR42118

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jun 3 2019, 3:41 PM
RKSimon accepted this revision.Jun 4 2019, 1:20 AM

LGTM - cheers

This revision is now accepted and ready to land.Jun 4 2019, 1:20 AM
xbolva00 accepted this revision.EditedJun 4 2019, 3:41 AM
xbolva00 added a subscriber: xbolva00.

Yes, it seems the more generalized form causes some regressions on Mips (missing folds?), but also it can improve PR31045.ll (@RKSimon) .

Anyway, this simpler form is fine.

This revision was automatically updated to reflect the committed changes.