Page MenuHomePhabricator

[InstCombine] reassociate logic ops with constants separated by a zext
ClosedPublic

Authored by spatel on Jul 15 2016, 12:29 PM.

Details

Summary

This is a partial implementation of a general fold for associative+commutative operators:
(op (cast (op X, C2)), C1) --> (cast (op X, op (C1, C2)))
(op (cast (op X, C2)), C1) --> (op (cast X), op (C1, C2))

There are 7 associative operators and 13 cast types, so this could potentially go a lot further. But I'd like to make sure this much is implemented properly before extending.

Also, the zext + logic case should be enough to allow D22271 to proceed.

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 64180.Jul 15 2016, 12:29 PM
spatel retitled this revision from to [InstCombine] reassociate logic ops with constants separated by a zext.
spatel updated this object.
spatel added reviewers: majnemer, eli.friedman, sanjoy.
spatel added a subscriber: llvm-commits.
majnemer accepted this revision.Jul 15 2016, 3:14 PM
majnemer edited edge metadata.

LGTM

This revision is now accepted and ready to land.Jul 15 2016, 3:14 PM
This revision was automatically updated to reflect the committed changes.