summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-07-06 21:01:26 +0000
committerSanjay Patel <spatel@rotateright.com>2016-07-06 21:01:26 +0000
commitea23436638012a1d401077b9b8774e3fa38c2ce3 (patch)
tree0db96a1bfbbe41a29440463f4676d0b7a6aee43b /llvm/lib/Transforms
parent24fe82982560b8361cb982c17eaee3d01141c60a (diff)
downloadbcm5719-llvm-ea23436638012a1d401077b9b8774e3fa38c2ce3.tar.gz
bcm5719-llvm-ea23436638012a1d401077b9b8774e3fa38c2ce3.zip
[InstCombine] use more specific pattern matchers; NFCI
Follow-up from r274465: we don't need to capture the value in these cases, so just match the constant that we're looking for. m_One/m_Zero work with vector splats as well as scalars. llvm-svn: 274670
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index c8ba0b89b48..d89691e5b92 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -920,22 +920,20 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
if (SI.getType()->getScalarType()->isIntegerTy(1) &&
TrueVal->getType() == CondVal->getType()) {
- const APInt *TrueC;
- if (match(TrueVal, m_APInt(TrueC))) {
- if (TrueC->isAllOnesValue()) {
- // Change: A = select B, true, C --> A = or B, C
- return BinaryOperator::CreateOr(CondVal, FalseVal);
- }
+ if (match(TrueVal, m_One())) {
+ // Change: A = select B, true, C --> A = or B, C
+ return BinaryOperator::CreateOr(CondVal, FalseVal);
+ }
+ if (match(TrueVal, m_Zero())) {
// Change: A = select B, false, C --> A = and !B, C
Value *NotCond = Builder->CreateNot(CondVal, "not." + CondVal->getName());
return BinaryOperator::CreateAnd(NotCond, FalseVal);
}
- const APInt *FalseC;
- if (match(FalseVal, m_APInt(FalseC))) {
- if (*FalseC == 0) {
- // Change: A = select B, C, false --> A = and B, C
- return BinaryOperator::CreateAnd(CondVal, TrueVal);
- }
+ if (match(FalseVal, m_Zero())) {
+ // Change: A = select B, C, false --> A = and B, C
+ return BinaryOperator::CreateAnd(CondVal, TrueVal);
+ }
+ if (match(FalseVal, m_One())) {
// Change: A = select B, C, true --> A = or !B, C
Value *NotCond = Builder->CreateNot(CondVal, "not." + CondVal->getName());
return BinaryOperator::CreateOr(NotCond, TrueVal);
OpenPOWER on IntegriCloud