Blame SOURCES/gcc48-pr80362.patch

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