Commit 737237c9 by Richard Biener Committed by Richard Biener

re PR middle-end/80362 (gcc miscompiles arithmetic with signed char)

2017-04-10  Richard Biener  <rguenther@suse.de>

	PR middle-end/80362
	* fold-const.c (fold_binary_loc): Look at unstripped ops when
	looking for NEGATE_EXPR in -A / -B to A / B folding.

	* gcc.dg/torture/pr80362.c: New testcase.

From-SVN: r246805
parent 541e0d55
2017-04-10 Richard Biener <rguenther@suse.de>
PR middle-end/80362
* fold-const.c (fold_binary_loc): Look at unstripped ops when
looking for NEGATE_EXPR in -A / -B to A / B folding.
2017-04-10 Martin Liska <mliska@suse.cz> 2017-04-10 Martin Liska <mliska@suse.cz>
PR gcov-profile/80224 PR gcov-profile/80224
......
...@@ -10205,7 +10205,7 @@ fold_binary_loc (location_t loc, ...@@ -10205,7 +10205,7 @@ fold_binary_loc (location_t loc,
/* Convert -A / -B to A / B when the type is signed and overflow is /* Convert -A / -B to A / B when the type is signed and overflow is
undefined. */ undefined. */
if ((!INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type)) if ((!INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))
&& TREE_CODE (arg0) == NEGATE_EXPR && TREE_CODE (op0) == NEGATE_EXPR
&& negate_expr_p (op1)) && negate_expr_p (op1))
{ {
if (INTEGRAL_TYPE_P (type)) if (INTEGRAL_TYPE_P (type))
......
2017-04-10 Richard Biener <rguenther@suse.de> 2017-04-10 Richard Biener <rguenther@suse.de>
PR middle-end/80362
* gcc.dg/torture/pr80362.c: New testcase.
2017-04-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/80304 PR tree-optimization/80304
* gcc.dg/torture/pr80304.c: New testcase. * gcc.dg/torture/pr80304.c: New testcase.
......
/* { dg-do run } */
/* { dg-additional-options "-fstrict-overflow" } */
int main()
{
signed char var_0, var_1 = -128;
var_0 = (signed char)(-var_1) / 3;
if (var_0 > 0)
__builtin_abort();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment