summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2017-04-17 20:49:50 +0000
committerDavide Italiano <davide@freebsd.org>2017-04-17 20:49:50 +0000
commitcdc937d0fc14315836b471834fec2ff341de240f (patch)
tree98c5ed3b8d0d3e5c5b53ee710aec0ebdc838e92f /llvm/lib/Transforms
parent8c4053372efb310560787e3beff07c41760dfdab (diff)
downloadbcm5719-llvm-cdc937d0fc14315836b471834fec2ff341de240f.tar.gz
bcm5719-llvm-cdc937d0fc14315836b471834fec2ff341de240f.zip
[InstCombine] Matchers work with both ConstExpr and Instructions.
So, `cast<Instruction>` is not guaranteed to succeed. Change the code so that we create a new constant and use it in the newly created instruction, as it's done in other places in InstCombine. OK'ed by Sanjay/Craig. Fixes PR32686. llvm-svn: 300495
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index b2a41c69920..2906d34ee3d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2078,7 +2078,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
Value *NOr = Builder->CreateOr(A, Op1);
NOr->takeName(Op0);
return BinaryOperator::CreateXor(NOr,
- cast<Instruction>(Op0)->getOperand(1));
+ ConstantInt::get(NOr->getType(), *C));
}
// Y|(X^C) -> (X|Y)^C iff Y&C == 0
@@ -2087,7 +2087,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) {
Value *NOr = Builder->CreateOr(A, Op0);
NOr->takeName(Op0);
return BinaryOperator::CreateXor(NOr,
- cast<Instruction>(Op1)->getOperand(1));
+ ConstantInt::get(NOr->getType(), *C));
}
}
OpenPOWER on IntegriCloud