From: Peter Bergner <peter@bergner.org>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
Bill Schmidt <wschmidt@linux.vnet.ibm.com>,
Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH, rs6000] Fix PR84279, powerpc64le ICE on cvc4
Date: Tue, 13 Feb 2018 03:34:00 -0000 [thread overview]
Message-ID: <31e557e6-4b62-eeca-a1a3-173397c205e7@bergner.org> (raw)
PR84279 is a similar problem to PR83399, in that we generate an altivec
load/store through an explicit call to the altivec_{l,st}vx_v4si_2op
pattern and then due to spilling, we end up calling recog() and we match
an earlier pattern, in this case vsx_movv4si_64bit. That is ok, since
this pattern can generate the lvx/stvx insns the altivec patterm can.
However, due to a constraint bug, we end up using the wrong alternative.
The problematic code after spilling looks like:
(insn 92 131 126 2 (parallel [
(set (reg:V4SI 140)
(unspec:V4SI [
(reg:SI 143 [ g ])
(reg:SI 150 [ ar.v ])
(subreg:SI (reg:DI 146) 0)
(subreg:SI (reg:DI 149) 0)
] UNSPEC_VSX_VEC_INIT))
(clobber (scratch:DI))
(clobber (scratch:DI))
]) "bug.i":25 1237 {vsx_init_v4si})
(insn 126 92 95 2 (set (mem/c:V4SI (and:DI (plus:DI (reg/f:DI 111 sfp)
(reg:DI 156))
(const_int -16 [0xfffffffffffffff0])) [3 MEM[(struct A *)&am]+0 S16 A128])
(reg:V4SI 140)) "bug.i":25 1792 {altivec_stvx_v4si_2op})
The vsx_init_v4si pattern forces pseudo 140 to be assigned a GPR, which
should force a reload in insn 126, because the altivec store requires
an altivec register for its src operand. However, after recog(), we
end up using the vsx_movv4si_64bit pattern which looks like:
(define_insn "*vsx_mov<mode>_64bit"
[(set (match_operand:VSX_M 0 "nonimmediate_operand"
"=ZwO, <VSa>, <VSa>, r, we, ?wQ,
?&r, ??r, ??Y, ??r, wo, v,
?<VSa>, *r, v, ??r, wZ, v")
(match_operand:VSX_M 1 "input_operand"
"<VSa>, ZwO, <VSa>, we, r, r,
wQ, Y, r, r, wE, jwM,
?jwM, jwM, W, W, v, wZ"))]
Now we _should_ match using the second to last alternative, but we end up
matching the 8th alternative ("??Y" and "r"). The 8th alternative is used for
storing a GPR, which we have, but the mem we're trying to store to does not
have a valid address for a GPR store. The "bug" is that the "Y" constraint
code, which is implemented by mem_operand_gpr() allows our altivec address
when it should not. The following patch which fixes the ICE adds code to
mem_operand_gpr() which disallows such addresses.
This patch passed bootstrap and retesting on powerpc64le-linux with
no regressions. Ok for mainline?
Peter
gcc/
PR target/84279
* config/rs6000/rs6000.c (mem_operand_gpr): Disallow altivec addresses.
gcc/testsuite/
PR target/84279
* g++.dg/pr84279.C: New test.
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c (revision 257606)
+++ gcc/config/rs6000/rs6000.c (working copy)
@@ -8220,6 +8220,12 @@ mem_operand_gpr (rtx op, machine_mode mo
int extra;
rtx addr = XEXP (op, 0);
+ /* Don't allow altivec type addresses like (mem (and (plus ...))).
+ See PR target/84279. */
+
+ if (GET_CODE (addr) == AND)
+ return false;
+
op = address_offset (addr);
if (op == NULL_RTX)
return true;
Index: gcc/testsuite/g++.dg/pr84279.C
===================================================================
--- gcc/testsuite/g++.dg/pr84279.C (nonexistent)
+++ gcc/testsuite/g++.dg/pr84279.C (working copy)
@@ -0,0 +1,35 @@
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
+/* { dg-options "-O3 -mcpu=power8 -g -fPIC -fvisibility=hidden -fstack-protector-strong" } */
+
+template <typename, typename T> struct E { T e; };
+struct J {
+ unsigned k, l;
+ J (unsigned x, unsigned y) : k(x), l(y) {}
+};
+typedef struct A {
+ J n, p;
+ A ();
+ A (J x, J y) : n(x), p(y) {}
+} *S;
+S t;
+struct B {
+ struct C {
+ S q, r;
+ int u, v;
+ bool m1 (S, A &);
+ J m2 () const;
+ J m3 () const;
+ A m4 () const;
+ };
+ typedef E<unsigned, S> D;
+ void m5 (D *);
+ void m6 (unsigned, A);
+};
+bool B::C::m1 (S, A &x) { bool o; x = m4 (); return o; }
+J B::C::m2 () const { unsigned g (u == 0); unsigned h (v); return J (g, h); }
+J B::C::m3 () const { unsigned g (q != t); unsigned h (r != t); return J (g, h); }
+A B::C::m4 () const { return A (m2 (), m3 ()); }
+void B::m5 (D *c) { unsigned x; C ar; A am; if (ar.m1 (c->e, am)) m6 (x, am); }
next reply other threads:[~2018-02-13 3:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 3:34 Peter Bergner [this message]
2018-02-13 22:34 ` Segher Boessenkool
2018-02-13 23:07 ` Peter Bergner
2018-02-13 23:51 ` Segher Boessenkool
2018-02-14 1:12 ` Peter Bergner
2018-02-14 15:19 ` Peter Bergner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=31e557e6-4b62-eeca-a1a3-173397c205e7@bergner.org \
--to=peter@bergner.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=segher@kernel.crashing.org \
--cc=wschmidt@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).