From: Jakub Jelinek Date: Tue, 5 Feb 2019 15:38:57 +0000 (+0100) Subject: re PR rtl-optimization/89195 (Corrupted stack offset after combine) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7356fbde50dd4bfd55eaa0bed31b31da55d1461c;p=gcc.git re PR rtl-optimization/89195 (Corrupted stack offset after combine) PR rtl-optimization/89195 * combine.c (make_extraction): For MEMs, don't extract bytes outside of the original MEM. * gcc.c-torture/execute/pr89195.c: New test. From-SVN: r268542 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a6c7f8c6c7a..c3340dbaf40 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-02-05 Jakub Jelinek + + PR rtl-optimization/89195 + * combine.c (make_extraction): For MEMs, don't extract bytes outside + of the original MEM. + 2019-02-05 Martin Liska PR gcov-profile/89000 diff --git a/gcc/combine.c b/gcc/combine.c index 7e1992f866f..a2492481693 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -7687,6 +7687,7 @@ make_extraction (machine_mode mode, rtx inner, HOST_WIDE_INT pos, /* We can't do this if we are widening INNER_MODE (it may not be aligned, for one thing). */ && !paradoxical_subreg_p (tmode, inner_mode) + && known_le (pos + len, GET_MODE_PRECISION (is_mode)) && (inner_mode == tmode || (! mode_dependent_address_p (XEXP (inner, 0), MEM_ADDR_SPACE (inner)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 90366221555..b232907be17 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-05 Jakub Jelinek + + PR rtl-optimization/89195 + * gcc.c-torture/execute/pr89195.c: New test. + 2019-02-05 Kelvin Nilsen * gcc.target/powerpc/vec-extract-slong-1.c: Require p8 execution diff --git a/gcc/testsuite/gcc.c-torture/execute/pr89195.c b/gcc/testsuite/gcc.c-torture/execute/pr89195.c new file mode 100644 index 00000000000..017f5b4309a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr89195.c @@ -0,0 +1,22 @@ +/* PR rtl-optimization/89195 */ +/* { dg-require-effective-target int32plus } */ + +struct S { unsigned i : 24; }; + +volatile unsigned char x; + +__attribute__((noipa)) int +foo (struct S d) +{ + return d.i & x; +} + +int +main () +{ + struct S d = { 0x123456 }; + x = 0x75; + if (foo (d) != (0x56 & 0x75)) + __builtin_abort (); + return 0; +}