From 0b838deddcfcb72b718728502e452da99c1b1c28 Mon Sep 17 00:00:00 2001 From: Michael Berg Date: Mon, 20 Aug 2018 22:26:58 +0000 Subject: extend binop folds for selects to include true and false binops flag intersection Summary: This change address bug 38641 Reviewers: spatel, wristow Reviewed By: spatel Differential Revision: https://reviews.llvm.org/D50996 llvm-svn: 340222 --- llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp') diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index 04fa2f95182..f09a67d96f3 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -355,7 +355,8 @@ Instruction *InstCombiner::foldSelectOpOp(SelectInst &SI, Instruction *TI, Value *Op1 = MatchIsOpZero ? NewSI : MatchOp; if (auto *BO = dyn_cast(TI)) { BinaryOperator *NewBO = BinaryOperator::Create(BO->getOpcode(), Op0, Op1); - NewBO->copyIRFlags(BO); + NewBO->copyIRFlags(TI); + NewBO->andIRFlags(FI); return NewBO; } if (auto *TGEP = dyn_cast(TI)) { -- cgit v1.2.3