This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] rtlanal: Fix bits/bytes confusion in set_noop_p (PR68814)
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Bernd Schmidt <bschmidt at redhat dot com>, gcc-patches at gcc dot gnu dot org, ebotcazou at adacore dot com
- Date: Fri, 15 Apr 2016 11:09:04 -0500
- Subject: Re: [PATCH] rtlanal: Fix bits/bytes confusion in set_noop_p (PR68814)
- Authentication-results: sourceware.org; auth=none
- References: <99c482971a4e6d16ff4bfe3b77bb1b890c73545b dot 1449691897 dot git dot segher at kernel dot crashing dot org> <20160415003514 dot GB25665 at gate dot crashing dot org> <5710D263 dot 2060000 at redhat dot com> <20160415114125 dot GM19207 at tucnak dot redhat dot com>
On Fri, Apr 15, 2016 at 01:41:25PM +0200, Jakub Jelinek wrote:
> On Fri, Apr 15, 2016 at 01:37:07PM +0200, Bernd Schmidt wrote:
> > On 04/15/2016 02:35 AM, Segher Boessenkool wrote:
> > >This now also shows up on GCC 5, see PR70672. It there happens in
> > >the jump1 pass already.
> > >
> > >Is this okay to backport to 5 and 4.9?
> >
> > Ok.
>
> Can you please also create a runtime testcase from PR70672 (unless it is
> roughly the same as the other PR) and commit to all branches?
I came up with this. I'll commit it in an hour or so unless someone
complains; it should work on all targets, BE and LE (tested on
powerpc64-linux and powerpc64le-linux).
So I now need to commit it to one more branch, yay :-)
Segher
gcc/testsuite/
PR rtl-optimization/70672
PR rtl-optimization/68814
* gcc.dg/pr70672.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/pr70672.c b/gcc/testsuite/gcc.dg/pr70672.c
new file mode 100644
index 0000000..d785124
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr70672.c
@@ -0,0 +1,64 @@
+/* PR rtl-optimization/70672 */
+/* PR rtl-optimization/68814 */
+/* { dg-do run { target { stdint_types } } } */
+/* { dg-options "-O2" } */
+
+#include <stdint.h>
+#include <stdlib.h>
+
+struct pair {
+ uint32_t one;
+ uint32_t two;
+};
+
+union u {
+ struct pair pair;
+ uint64_t num;
+};
+
+uint64_t __attribute__ ((noinline))
+f(uint64_t a)
+{
+ union u x;
+
+ x.num = a;
+
+ x.pair.one = x.pair.two;
+ x.pair.two = 0;
+
+ return x.num;
+}
+
+uint64_t __attribute__ ((noinline))
+g(uint64_t a)
+{
+ union u x;
+
+ x.num = a;
+
+ x.pair.two = x.pair.one;
+ x.pair.one = 0;
+
+ return x.num;
+}
+
+int
+main (void)
+{
+ uint64_t x = 0x123456789abcdef0ULL;
+ uint64_t fx = f(x);
+ uint64_t gx = g(x);
+ uint64_t fgx = f(gx);
+ uint64_t gfx = g(fx);
+
+ if ((fx & gx))
+ abort ();
+
+ if ((fgx & gfx))
+ abort ();
+
+ if ((fgx | gfx) != x)
+ abort ();
+
+ return 0;
+}