Add missing int_cst_rangeN checks to tree-vrp.c
commitc4a8fb872df47e3630032f7fcf8bb8198ed89e8a
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Sep 2017 10:53:40 +0000 (21 10:53 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Sep 2017 10:53:40 +0000 (21 10:53 +0000)
tree59b4e3115a78832a2f6d4c77bc03dc1469d6a21d
parent046c4ba66f6cb1c4c6c0188dca6cd17957d664a9
Add missing int_cst_rangeN checks to tree-vrp.c

The BIT_AND_EXPR handling in extract_range_from_binary_expr_1
was using value_range_constant_singleton without first checking
whether the range was a constant.  The earlier handling was correctly
guarded:

  /* If either input range contains only non-negative values
     we can truncate the result range maximum to the respective
     maximum of the input range.  */
  if (int_cst_range0 && tree_int_cst_sgn (vr0.min) >= 0)
    wmax = wi::min (wmax, vr0.max, TYPE_SIGN (expr_type));
  if (int_cst_range1 && tree_int_cst_sgn (vr1.min) >= 0)
    wmax = wi::min (wmax, vr1.max, TYPE_SIGN (expr_type));

so this patch uses the same guards again.

Existing tests showed the need for this once polynomial constants
are added.

2017-09-21  Richard Sandiford  <richard.sandiford@linaro.org>
    Alan Hayward  <alan.hayward@arm.com>
    David Sherwood  <david.sherwood@arm.com>

gcc/
* tree-vrp.c (extract_range_from_binary_expr_1): Check
int_cst_rangeN before calling value_range_constant_singleton (&vrN).

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253054 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/tree-vrp.c