diff options
author | Haicheng Wu <haicheng@codeaurora.org> | 2017-10-02 23:43:52 +0000 |
---|---|---|
committer | Haicheng Wu <haicheng@codeaurora.org> | 2017-10-02 23:43:52 +0000 |
commit | f7bb6862c7de232d24c399930ef921ecfe685824 (patch) | |
tree | ac4e9563f9c155e2042287a53ca320bd10b1bdad /include | |
parent | 0e47622a91ad77b20fb86147bf23576897050ef3 (diff) |
[InstSimplify] teach SimplifySelectInst() to fold more vector selects
Call ConstantFoldSelectInstruction() to fold cases like below
select <2 x i1><i1 true, i1 false>, <2 x i8> <i8 0, i8 1>, <2 x i8> <i8 2, i8 3>
All operands are constants and the condition has mixed true and false conditions.
Differential Revision: https://reviews.llvm.org/D38369
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Analysis/ConstantFolding.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/llvm/Analysis/ConstantFolding.h b/include/llvm/Analysis/ConstantFolding.h index 42034741b8e..cb314e3766c 100644 --- a/include/llvm/Analysis/ConstantFolding.h +++ b/include/llvm/Analysis/ConstantFolding.h @@ -79,6 +79,12 @@ ConstantFoldCompareInstOperands(unsigned Predicate, Constant *LHS, Constant *ConstantFoldBinaryOpOperands(unsigned Opcode, Constant *LHS, Constant *RHS, const DataLayout &DL); +/// \brief Attempt to constant fold a select instruction with the specified +/// operands. The constant result is returned if successful; if not, null is +/// returned. +Constant *ConstantFoldSelectInstruction(Constant *Cond, Constant *V1, + Constant *V2); + /// \brief Attempt to constant fold a cast with the specified operand. If it /// fails, it returns a constant expression of the specified operand. Constant *ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, |