summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2015-08-27 21:46:04 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2015-08-27 21:46:04 +0000
commit87166905c8d58e152b06752f5d2f24a09ebbcbde (patch)
tree3588fa419651f825a09c7dee499f47cb530137a9 /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent8f5e331dc2650a6729401ba38aaa04d0e98cd966 (diff)
downloadbcm5719-llvm-87166905c8d58e152b06752f5d2f24a09ebbcbde.tar.gz
bcm5719-llvm-87166905c8d58e152b06752f5d2f24a09ebbcbde.zip
[CodeGen] Check FoldConstantArithmetic result before using it.
Fixes PR24602: r245689 introduced an unguarded use of SelectionDAG::FoldConstantArithmetic, which returns 0 when it fails because of opaque (hoisted) constants. llvm-svn: 246217
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 3275daf3ffd..693331fc19e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4457,8 +4457,9 @@ SDValue DAGCombiner::visitSHL(SDNode *N) {
// fold (shl (mul x, c1), c2) -> (mul x, c1 << c2)
if (N1C && N0.getOpcode() == ISD::MUL && N0.getNode()->hasOneUse()) {
if (ConstantSDNode *N0C1 = isConstOrConstSplat(N0.getOperand(1))) {
- SDValue Folded = DAG.FoldConstantArithmetic(ISD::SHL, SDLoc(N1), VT, N0C1, N1C);
- return DAG.getNode(ISD::MUL, SDLoc(N), VT, N0.getOperand(0), Folded);
+ if (SDValue Folded =
+ DAG.FoldConstantArithmetic(ISD::SHL, SDLoc(N1), VT, N0C1, N1C))
+ return DAG.getNode(ISD::MUL, SDLoc(N), VT, N0.getOperand(0), Folded);
}
}
OpenPOWER on IntegriCloud