SDOperand FoldedVOp = SimplifyVBinOp(N);
if (FoldedVOp.Val) return FoldedVOp;
+ // fold (add x, undef) -> undef
+ if (N1.getOpcode() == ISD::UNDEF)
+ return N1;
// fold (add c1, c2) -> c1+c2
if (N0C && N1C)
return DAG.getNode(ISD::ADD, VT, N0, N1);
if (Result.Val) return Result;
}
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
-
return SDOperand();
}
SDOperand Result = combineSelectAndUse(N, N1, N0, DAG);
if (Result.Val) return Result;
}
- // If either operand is undef, the result is undef
+ // If either operand of a sub is undef, the result is undef
if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
return DAG.getNode(ISD::UNDEF, VT);
SDOperand FoldedVOp = SimplifyVBinOp(N);
if (FoldedVOp.Val) return FoldedVOp;
+ // fold (mul x, undef) -> 0
+ if (N1.getOpcode() == ISD::UNDEF)
+ return DAG.getConstant(0, VT);
// fold (mul c1, c2) -> c1*c2
if (N0C && N1C)
return DAG.getNode(ISD::MUL, VT, N0, N1);
if (RMUL.Val != 0)
return RMUL;
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
-
return SDOperand();
}
if (Op.Val) return Op;
}
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
+ // undef / X -> 0
+ if (N0.getOpcode() == ISD::UNDEF)
+ return DAG.getConstant(0, VT);
+ // X / undef -> undef
+ if (N1.getOpcode() == ISD::UNDEF)
+ return N1;
return SDOperand();
}
if (Op.Val) return Op;
}
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
+ // undef / X -> 0
+ if (N0.getOpcode() == ISD::UNDEF)
+ return DAG.getConstant(0, VT);
+ // X / undef -> undef
+ if (N1.getOpcode() == ISD::UNDEF)
+ return N1;
return SDOperand();
}
return Sub;
}
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
+ // undef % X -> 0
+ if (N0.getOpcode() == ISD::UNDEF)
+ return DAG.getConstant(0, VT);
+ // X % undef -> undef
+ if (N1.getOpcode() == ISD::UNDEF)
+ return N1;
return SDOperand();
}
return Sub;
}
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
+ // undef % X -> 0
+ if (N0.getOpcode() == ISD::UNDEF)
+ return DAG.getConstant(0, VT);
+ // X % undef -> undef
+ if (N1.getOpcode() == ISD::UNDEF)
+ return N1;
return SDOperand();
}
return DAG.getNode(ISD::SRA, N0.getValueType(), N0,
DAG.getConstant(MVT::getSizeInBits(N0.getValueType())-1,
TLI.getShiftAmountTy()));
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
+ // fold (mulhs x, undef) -> 0
+ if (N1.getOpcode() == ISD::UNDEF)
+ return DAG.getConstant(0, VT);
return SDOperand();
}
// fold (mulhu x, 1) -> 0
if (N1C && N1C->getValue() == 1)
return DAG.getConstant(0, N0.getValueType());
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
+ // fold (mulhu x, undef) -> 0
+ if (N1.getOpcode() == ISD::UNDEF)
+ return DAG.getConstant(0, VT);
return SDOperand();
}
return DAG.getNode(N0.getOpcode(), VT, ORNode, N0.getOperand(1));
}
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
-
return SDOperand();
}
SDOperand FoldedVOp = SimplifyVBinOp(N);
if (FoldedVOp.Val) return FoldedVOp;
+ // fold (and x, undef) -> 0
+ if (N1.getOpcode() == ISD::UNDEF)
+ return DAG.getConstant(0, VT);
// fold (and c1, c2) -> c1&c2
if (N0C && N1C)
return DAG.getNode(ISD::AND, VT, N0, N1);
SDOperand FoldedVOp = SimplifyVBinOp(N);
if (FoldedVOp.Val) return FoldedVOp;
+ // fold (or x, undef) -> -1
+ if (N1.getOpcode() == ISD::UNDEF)
+ return DAG.getConstant(-1, VT);
// fold (or c1, c2) -> c1|c2
if (N0C && N1C)
return DAG.getNode(ISD::OR, VT, N0, N1);
SDOperand FoldedVOp = SimplifyVBinOp(N);
if (FoldedVOp.Val) return FoldedVOp;
+ // fold (xor x, undef) -> undef
+ if (N1.getOpcode() == ISD::UNDEF)
+ return N1;
// fold (xor c1, c2) -> c1^c2
if (N0C && N1C)
return DAG.getNode(ISD::XOR, VT, N0, N1);
return DAG.getNode(ISD::FADD, VT, N0.getOperand(0),
DAG.getNode(ISD::FADD, VT, N0.getOperand(1), N1));
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
-
return SDOperand();
}
if (isNegatibleForFree(N1))
return DAG.getNode(ISD::FADD, VT, N0, GetNegatedExpression(N1, DAG));
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
-
return SDOperand();
}
return DAG.getNode(ISD::FMUL, VT, N0.getOperand(0),
DAG.getNode(ISD::FMUL, VT, N0.getOperand(1), N1));
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
-
return SDOperand();
}
}
}
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
-
return SDOperand();
}
if (N0CFP && N1CFP)
return DAG.getNode(ISD::FREM, VT, N0, N1);
- // If either operand is undef, the result is undef
- if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
- return DAG.getNode(ISD::UNDEF, VT);
-
return SDOperand();
}