diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-11-08 23:49:15 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-11-08 23:49:15 +0000 |
commit | 99dc5feff144a4183a67d66833c51fc7f2444ff9 (patch) | |
tree | 9b83f66b5435670b28ade8f29573514cfecbb70f /llvm/lib/Transforms | |
parent | 2d56c265046de717dd117c248c3ba8d2a5ff7a5d (diff) | |
download | bcm5719-llvm-99dc5feff144a4183a67d66833c51fc7f2444ff9.tar.gz bcm5719-llvm-99dc5feff144a4183a67d66833c51fc7f2444ff9.zip |
[InstCombine] reduce indentation; NFC
llvm-svn: 286314
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index 6121b80f23b..6bee87c5d10 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -1305,29 +1305,26 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { } // MAX(~a, ~b) -> ~MIN(a, b) - if (SPF == SPF_SMAX || SPF == SPF_UMAX) { - if (IsFreeToInvert(LHS, LHS->hasNUses(2)) && - IsFreeToInvert(RHS, RHS->hasNUses(2))) { - - // This transform adds a xor operation and that extra cost needs to be - // justified. We look for simplifications that will result from - // applying this rule: - - bool Profitable = - (LHS->hasNUses(2) && match(LHS, m_Not(m_Value()))) || - (RHS->hasNUses(2) && match(RHS, m_Not(m_Value()))) || - (SI.hasOneUse() && match(*SI.user_begin(), m_Not(m_Value()))); - - if (Profitable) { - Value *NewLHS = Builder->CreateNot(LHS); - Value *NewRHS = Builder->CreateNot(RHS); - Value *NewCmp = SPF == SPF_SMAX - ? Builder->CreateICmpSLT(NewLHS, NewRHS) - : Builder->CreateICmpULT(NewLHS, NewRHS); - Value *NewSI = - Builder->CreateNot(Builder->CreateSelect(NewCmp, NewLHS, NewRHS)); - return replaceInstUsesWith(SI, NewSI); - } + if ((SPF == SPF_SMAX || SPF == SPF_UMAX) && + IsFreeToInvert(LHS, LHS->hasNUses(2)) && + IsFreeToInvert(RHS, RHS->hasNUses(2))) { + // This transform adds a not operation, and that extra cost needs to be + // justified. We look for simplifications that will result from applying + // this rule: + bool Profitable = + (LHS->hasNUses(2) && match(LHS, m_Not(m_Value()))) || + (RHS->hasNUses(2) && match(RHS, m_Not(m_Value()))) || + (SI.hasOneUse() && match(*SI.user_begin(), m_Not(m_Value()))); + + if (Profitable) { + Value *NewLHS = Builder->CreateNot(LHS); + Value *NewRHS = Builder->CreateNot(RHS); + Value *NewCmp = SPF == SPF_SMAX + ? Builder->CreateICmpSLT(NewLHS, NewRHS) + : Builder->CreateICmpULT(NewLHS, NewRHS); + Value *NewSI = + Builder->CreateNot(Builder->CreateSelect(NewCmp, NewLHS, NewRHS)); + return replaceInstUsesWith(SI, NewSI); } } |