From: Jakub Jelinek Date: Fri, 16 Sep 2016 07:09:27 +0000 (+0200) Subject: re PR middle-end/77594 (double computation for __builtin_sub_overflow (0, ...)) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7d704548e7aabca540cc173f70df1e0dcfc6304c;p=gcc.git re PR middle-end/77594 (double computation for __builtin_sub_overflow (0, ...)) PR middle-end/77594 * internal-fn.c (expand_arith_overflow) : Don't fall through into expand_addsub_overflow after expand_neg_overflow. * gcc.target/i386/pr77594.c: New test. Co-Authored-By: Eric Botcazou From-SVN: r240173 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d103ae65fe4..0287d52c5e0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-09-16 Jakub Jelinek + Eric Botcazou + + PR middle-end/77594 + * internal-fn.c (expand_arith_overflow) : Don't fall + through into expand_addsub_overflow after expand_neg_overflow. + 2016-09-15 David Malcolm * diagnostic-show-locus.c diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index cd4b6254c81..c269ca6b940 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -1833,7 +1833,10 @@ expand_arith_overflow (enum tree_code code, gimple *stmt) { case MINUS_EXPR: if (integer_zerop (arg0) && !unsr_p) - expand_neg_overflow (loc, lhs, arg1, false); + { + expand_neg_overflow (loc, lhs, arg1, false); + return; + } /* FALLTHRU */ case PLUS_EXPR: expand_addsub_overflow (loc, code, lhs, arg0, arg1, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3c2087528a9..8d739b5a759 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-09-16 Jakub Jelinek + Eric Botcazou + + PR middle-end/77594 + * gcc.target/i386/pr77594.c: New test. + 2016-09-15 Louis Krupp PR fortran/69963 diff --git a/gcc/testsuite/gcc.target/i386/pr77594.c b/gcc/testsuite/gcc.target/i386/pr77594.c new file mode 100644 index 00000000000..96c51fd71fa --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr77594.c @@ -0,0 +1,11 @@ +/* PR middle-end/77594 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +int +foo (int a, int *b) +{ + return __builtin_sub_overflow (0, a, b); +} + +/* { dg-final { scan-assembler-times "\tjn?o\t" 1 } } */