[InstCombine] reassociate logic ops with constants separated by a zext
authorSanjay Patel <spatel@rotateright.com>
Sat, 16 Jul 2016 15:20:19 +0000 (15:20 +0000)
committerSanjay Patel <spatel@rotateright.com>
Sat, 16 Jul 2016 15:20:19 +0000 (15:20 +0000)
commitf9d2b20daff1251bb53b02a7e12ba20324da106f
tree2e3bf9a65eb7a23a7b8c31e09ab32738e9059cac
parentee0e63804f2aeb0e129ebc6d9c897e91ca979a3f
[InstCombine] reassociate logic ops with constants separated by a zext

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.

Differential Revision: https://reviews.llvm.org/D22421

llvm-svn: 275684
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/assoc-cast-assoc.ll