[InstCombine] Whitelist non-refining folds in SimplifyWithOpReplaced
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 20 Mar 2021 20:01:49 +0000 (21:01 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 22 Mar 2021 21:12:56 +0000 (22:12 +0100)
commit7e18cd887cd402e3d5465c57c218079e4df65231
tree074f7caedd4ab0bb23d87fae7ccad88ccaa018eb
parent8b35159ac720fcb9914e4931b416e17b0fbda771
[InstCombine] Whitelist non-refining folds in SimplifyWithOpReplaced

This is an alternative to D98391/D98585, playing things more
conservatively. If AllowRefinement == false, then we don't use
InstSimplify methods at all, and instead explicitly implement a
small number of non-refining folds. Most cases are handled by
constant folding, and I only had to add three folds to cover
our unit tests / test-suite. While this may lose some optimization
power, I think it is safer to approach from this direction, given
how many issues this code has already caused.

Differential Revision: https://reviews.llvm.org/D99027
llvm/include/llvm/Analysis/InstructionSimplify.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/minmax-fold.ll
llvm/test/Transforms/InstCombine/select.ll
llvm/test/Transforms/InstSimplify/pr49495.ll