From: Jakub Jelinek Date: Thu, 14 Mar 2019 12:21:36 +0000 (+0100) Subject: re PR rtl-optimization/89679 (wrong code with -Og -frerun-cse-after-loop -fno-tree... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=87654f1813a0f582645f72d87f7fb8c78b92ee6a;p=gcc.git re PR rtl-optimization/89679 (wrong code with -Og -frerun-cse-after-loop -fno-tree-fre) PR rtl-optimization/89679 * expmed.c (expand_mult_const): Don't add a REG_EQUAL note if it would contain a paradoxical SUBREG. * gcc.dg/pr89679.c: New test. From-SVN: r269680 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 329954b78ac..fb9a555b59a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-03-14 Jakub Jelinek + + PR rtl-optimization/89679 + * expmed.c (expand_mult_const): Don't add a REG_EQUAL note if it + would contain a paradoxical SUBREG. + 2019-03-14 Richard Biener PR tree-optimization/89710 diff --git a/gcc/expmed.c b/gcc/expmed.c index b7f55a7e73b..d7f8e9a5d76 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -3356,13 +3356,20 @@ expand_mult_const (machine_mode mode, rtx op0, HOST_WIDE_INT val, tem = gen_lowpart (nmode, op0); } - insn = get_last_insn (); - wide_int wval_so_far - = wi::uhwi (val_so_far, - GET_MODE_PRECISION (as_a (nmode))); - rtx c = immed_wide_int_const (wval_so_far, nmode); - set_dst_reg_note (insn, REG_EQUAL, gen_rtx_MULT (nmode, tem, c), - accum_inner); + /* Don't add a REG_EQUAL note if tem is a paradoxical SUBREG. + In that case, only the low bits of accum would be guaranteed to + be equal to the content of the REG_EQUAL note, the upper bits + can be anything. */ + if (!paradoxical_subreg_p (tem)) + { + insn = get_last_insn (); + wide_int wval_so_far + = wi::uhwi (val_so_far, + GET_MODE_PRECISION (as_a (nmode))); + rtx c = immed_wide_int_const (wval_so_far, nmode); + set_dst_reg_note (insn, REG_EQUAL, gen_rtx_MULT (nmode, tem, c), + accum_inner); + } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3536cf145e2..19c319e0691 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-14 Jakub Jelinek + + PR rtl-optimization/89679 + * gcc.dg/pr89679.c: New test. + 2019-03-14 Richard Biener PR tree-optimization/89710 diff --git a/gcc/testsuite/gcc.dg/pr89679.c b/gcc/testsuite/gcc.dg/pr89679.c new file mode 100644 index 00000000000..0d6e2d2c871 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr89679.c @@ -0,0 +1,26 @@ +/* PR rtl-optimization/89679 */ +/* { dg-do run } */ +/* { dg-options "-Og -frerun-cse-after-loop -fno-tree-fre" } */ + +unsigned short g; + +void +foo (unsigned long long x) +{ + if (x != 0xffff) + __builtin_abort (); +} + +int +main () +{ +#if __SIZEOF_SHORT__ == 2 && __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8 + unsigned short d = 0; + unsigned long long x, c = ~0; + c = c >> d; + __builtin_memset (&d, c, 2); + x = d + g; + foo (x); +#endif + return 0; +}