[ConstantFold] Handle identity folds at top of ConstantFoldBinaryInst
authorFlorian Hahn <flo@fhahn.com>
Sun, 17 Nov 2019 21:29:55 +0000 (21:29 +0000)
committerFlorian Hahn <flo@fhahn.com>
Sun, 17 Nov 2019 21:30:14 +0000 (21:30 +0000)
commit8eeabbaf5da31f44b42f0ef7d625640570b0a620
tree6fb5eeb827561f7034b7ee27ad6f22c84a959919
parent28c183859ae0e92b638721a738019fe7265910a5
[ConstantFold] Handle identity folds at top of ConstantFoldBinaryInst

Currently we miss folds with undef and identity values for binary ops
that do not fold to undef in general.

We can generalize the identity simplifications and do them before
checking for undef in particular.

Alive checks:
 * OR - https://rise4fun.com/Alive/8OsK
 * AND - https://rise4fun.com/Alive/e3tE

This will also allow us to remove some now redundant cases throughout
the function, but I would like to do this as follow-up. That should make
tracking down potential issues easier.

Reviewers: spatel, RKSimon, lebedev.ri

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D70169
llvm/lib/IR/ConstantFold.cpp
llvm/test/Analysis/ConstantFolding/binop-identity-undef.ll
llvm/test/Transforms/InstCombine/vec_shuffle.ll