OSDN Git Service

[InstCombine] Add select simplifications
authorQuentin Colombet <qcolombet@apple.com>
Wed, 20 Sep 2017 17:32:16 +0000 (17:32 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Wed, 20 Sep 2017 17:32:16 +0000 (17:32 +0000)
commit9a4ebf5dc97fadd0b1f302dab44fa43aada20ff3
tree6dac27b6e9c6fc7b7b351cd42911bd0d076c55f2
parent0ee89615039a4f99c96a5ef6b94a10caca598b27
[InstCombine] Add select simplifications

In these cases, two selects have constant selectable operands for
both the true and false components and have the same conditional
expression.
We then create two arithmetic operations of the same type and feed a
final select operation using the result of the true arithmetic for the true
operand and the result of the false arithmetic for the false operand and reuse
the original conditionl expression.
The arithmetic operations are naturally folded as a consequence, leaving
only the newly formed select to replace the old arithmetic operation.

Patch by: Michael Berg <michael_c_berg@apple.com>
Differential Revision: https://reviews.llvm.org/D37019

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313774 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAddSub.cpp
lib/Transforms/InstCombine/InstCombineInternal.h
lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/InstCombine/select_arithmetic.ll [new file with mode: 0644]