From 428ded17977c8142625804eb8f7545ae7bb06f7b Mon Sep 17 00:00:00 2001 From: Yvan Roux Date: Tue, 12 Jan 2016 16:25:46 +0100 Subject: gcc/ Backport from trunk r230786. 2015-11-24 Segher Boessenkool PR rtl-optimization/68381 * combine.c (is_parallel_of_n_reg_sets): Return false if the pattern is poisoned. gcc/testsuite/ Backport from trunk r230809. 2015-11-24 Kyrylo Tkachov PR rtl-optimization/68381 * gcc.c-torture/execute/pr68381.c: New test. gcc/ Backport from trunk r230946. 2015-11-26 Kyrylo Tkachov * combine.c (subst): Do not return clobber of zero in widening mult case. Just return x unchanged if it is a no-op substitution. Change-Id: I3a644b62bce1ddd7d24ebd3b2c604076e040d755 --- gcc/combine.c | 16 +++++++--------- gcc/testsuite/gcc.c-torture/execute/pr68381.c | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr68381.c (limited to 'gcc') diff --git a/gcc/combine.c b/gcc/combine.c index ba9dd61626f..c903db2c8b0 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -2558,7 +2558,8 @@ is_parallel_of_n_reg_sets (rtx pat, int n) || !REG_P (SET_DEST (XVECEXP (pat, 0, i)))) return false; for ( ; i < len; i++) - if (GET_CODE (XVECEXP (pat, 0, i)) != CLOBBER) + if (GET_CODE (XVECEXP (pat, 0, i)) != CLOBBER + || XEXP (XVECEXP (pat, 0, i), 0) == const0_rtx) return false; return true; @@ -5316,7 +5317,7 @@ subst (rtx x, rtx from, rtx to, int in_dest, int in_cond, int unique_copy) || GET_CODE (SET_DEST (x)) == PC)) fmt = "ie"; - /* Substituting into the operands of a widening MULT is not likely + /* Trying to simplify the operands of a widening MULT is not likely to create RTL matching a machine insn. */ if (code == MULT && (GET_CODE (XEXP (x, 0)) == ZERO_EXTEND @@ -5324,13 +5325,10 @@ subst (rtx x, rtx from, rtx to, int in_dest, int in_cond, int unique_copy) && (GET_CODE (XEXP (x, 1)) == ZERO_EXTEND || GET_CODE (XEXP (x, 1)) == SIGN_EXTEND) && REG_P (XEXP (XEXP (x, 0), 0)) - && REG_P (XEXP (XEXP (x, 1), 0))) - { - if (from == to) - return x; - else - return gen_rtx_CLOBBER (GET_MODE (x), const0_rtx); - } + && REG_P (XEXP (XEXP (x, 1), 0)) + && from == to) + return x; + /* Get the mode of operand 0 in case X is now a SIGN_EXTEND of a constant. */ diff --git a/gcc/testsuite/gcc.c-torture/execute/pr68381.c b/gcc/testsuite/gcc.c-torture/execute/pr68381.c new file mode 100644 index 00000000000..cb6abcb265b --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr68381.c @@ -0,0 +1,22 @@ +/* { dg-options "-O -fexpensive-optimizations -fno-tree-bit-ccp" } */ + +__attribute__ ((noinline, noclone)) +int +foo (unsigned short x, unsigned short y) +{ + int r; + if (__builtin_mul_overflow (x, y, &r)) + __builtin_abort (); + return r; +} + +int +main (void) +{ + int x = 1; + int y = 2; + if (foo (x, y) != x * y) + __builtin_abort (); + return 0; +} + -- cgit v1.2.3