Blame SOURCES/gcc48-pr80362.patch

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