class operator_div : public cross_product_operator
{
using range_operator::update_bitmask;
+ using range_operator::op2_range;
public:
operator_div (tree_code div_kind) { m_code = div_kind; }
+ bool op2_range (irange &r, tree type, const irange &lhs, const irange &,
+ relation_trio) const;
virtual void wi_fold (irange &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
static operator_div op_round_div (ROUND_DIV_EXPR);
static operator_div op_ceil_div (CEIL_DIV_EXPR);
+// Set OP2 to non-zero if the LHS isn't UNDEFINED.
+bool
+operator_div::op2_range (irange &r, tree type, const irange &lhs,
+ const irange &, relation_trio) const
+{
+ if (!lhs.undefined_p ())
+ {
+ r.set_nonzero (type);
+ return true;
+ }
+ return false;
+}
+
bool
operator_div::wi_op_overflows (wide_int &res, tree type,
const wide_int &w0, const wide_int &w1) const
--- /dev/null
+// { dg-do compile }
+// { dg-options "-O2 -fdump-tree-evrp" }
+
+int always1(int a, int b) {
+ if (a / b)
+ return b != 0;
+ return 1;
+}
+
+// If b != 0 is optimized by recognizing divide by 0 cannot happen,
+// there should be no PHI node.
+
+// { dg-final { scan-tree-dump-not "PHI" "evrp" } }