Apparently we can't expect a BinaryOperator here.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 8 Jul 2011 12:08:24 +0000 (12:08 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 8 Jul 2011 12:08:24 +0000 (12:08 +0000)
Should fix llvm-gcc selfhost.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134699 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

index 2a362ebfc2d15c86f3b46a5023175f8f45e8d0dd..2afec3328b96d2d1d5a4c2e748e396951f5184e1 100644 (file)
@@ -2502,14 +2502,14 @@ void SelectionDAGBuilder::visitShift(const User &I, unsigned Opcode) {
 }
 
 void SelectionDAGBuilder::visitSDiv(const User &I) {
-  const BinaryOperator *BO = cast<BinaryOperator>(&I);
   SDValue Op1 = getValue(I.getOperand(0));
   SDValue Op2 = getValue(I.getOperand(1));
 
   // Turn exact SDivs into multiplications.
   // FIXME: This should be in DAGCombiner, but it doesn't have access to the
   // exact bit.
-  if (BO->isExact() && !isa<ConstantSDNode>(Op1) &&
+  if (isa<BinaryOperator>(&I) && cast<BinaryOperator>(&I)->isExact() &&
+      !isa<ConstantSDNode>(Op1) &&
       isa<ConstantSDNode>(Op2) && !cast<ConstantSDNode>(Op2)->isNullValue())
     setValue(&I, TLI.BuildExactSDIV(Op1, Op2, getCurDebugLoc(), DAG));
   else