This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] [PR tree-optimization/79095][PATCH 2/4] Add infrastructure to detect overflow checks


On 02/06/2017 05:52 AM, Richard Biener wrote:
+      /* Now look at the defining statement of OP1 to see if it adds
+        or subtracts a nonzero constant from another operand.  */
+      if (op1_def
+         && is_gimple_assign (op1_def)
+         && gimple_assign_rhs_code (op1_def) == PLUS_EXPR
+         && TREE_CODE (gimple_assign_rhs2 (op1_def)) == INTEGER_CST
+         && wi::ne_p (gimple_assign_rhs2 (op1_def), 0))

! integer_zerop ()
Fixed.

+
+         tree type = TREE_TYPE (op0);
+         wide_int max = wi::max_value (TYPE_PRECISION (type), UNSIGNED);
+         HOST_WIDE_INT inc = TREE_INT_CST_LOW (gimple_assign_rhs2
(op1_def));

You nowhere tested that rhs2 fits a HOST_WIDE_INT.  You can simply make inc
a tree and use that in the max + inc expression below.
Also fixed.


I'll have to see where the function is used to make sense of it.
Understood.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]