Blame SOURCES/gcc48-pr80362.patch

56d343
2017-09-18  Richard Biener  <rguenther@suse.de>
56d343
56d343
	Backport from mainline
56d343
	2017-04-10  Richard Biener  <rguenther@suse.de>
56d343
56d343
	PR middle-end/80362
56d343
	* fold-const.c (fold_binary_loc): Look at unstripped ops when
56d343
	looking for NEGATE_EXPR in -A / -B to A / B folding.
56d343
56d343
	* gcc.dg/torture/pr80362.c: New testcase.
56d343
56d343
--- gcc/fold-const.c
56d343
+++ gcc/fold-const.c
56d343
@@ -11940,8 +11942,8 @@ fold_binary_loc (location_t loc,
56d343
       /* Convert -A / -B to A / B when the type is signed and overflow is
56d343
 	 undefined.  */
56d343
       if ((!INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))
56d343
-	  && TREE_CODE (arg0) == NEGATE_EXPR
56d343
-	  && negate_expr_p (arg1))
56d343
+	  && TREE_CODE (op0) == NEGATE_EXPR
56d343
+	  && negate_expr_p (op1))
56d343
 	{
56d343
 	  if (INTEGRAL_TYPE_P (type))
56d343
 	    fold_overflow_warning (("assuming signed overflow does not occur "
56d343
--- /dev/null
56d343
+++ gcc/testsuite/gcc.dg/torture/pr80362.c
56d343
@@ -0,0 +1,11 @@
56d343
+/* { dg-do run } */
56d343
+/* { dg-additional-options "-fstrict-overflow" } */
56d343
+
56d343
+int main()
56d343
+{
56d343
+  signed char var_0, var_1 = -128;
56d343
+  var_0 = (signed char)(-var_1) / 3;
56d343
+  if (var_0 > 0)
56d343
+    __builtin_abort();
56d343
+  return 0;
56d343
+}