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: [PATCH] integer overflow checking builtins in constant expressions


On 05/01/2016 12:39 PM, Martin Sebor wrote:
+  if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST)
+    {
+      if (tree result = size_binop_loc (EXPR_LOC_OR_LOC (t, input_location),
+					opcode, arg0, arg1))
+	{
+	  if (TREE_OVERFLOW (result))
+	    {
+	      /* Reset TREE_OVERFLOW to avoid warnings for the overflow.  */
+	      TREE_OVERFLOW (result) = 0;
+
+	      return build_complex (TREE_TYPE (t), result, integer_one_node);
+	    }
+
+	  return build_complex (TREE_TYPE (t), result, integer_zero_node);
+	}
+    }

Should this be in the middle-end somewhere, perhaps shared with fold_builtin_arith_overflow? I notice that the comment for that function says that it folds into normal arithmetic if the operation can never overflow, but I don't see any code that would accomplish that.

Jason


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