* [PATCH] Fix powerpc* ICE with vec builtins with -mno-altivec (PR target/82848)
@ 2017-11-23 21:22 Jakub Jelinek
2017-11-25 8:40 ` Segher Boessenkool
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2017-11-23 21:22 UTC (permalink / raw)
To: Segher Boessenkool, David Edelsohn, Will Schmidt; +Cc: gcc-patches
Hi!
With -mno-altivec -mno-vsx -mno-fold-gimple we error on __builtin_vec*
builtins used when corresponding ISA is not enabled.
When folding gimple, in some cases we get away with it (e.g. when folding
the builtin to PLUS_EXPR on the generic vectors), because
tree-vect-generic.c lowers those into scalar piecewise operations,
but e.g. in case of FMA_EXPR tree-vect-generic.c isn't doing anything,
expects that FMA_EXPR is actually used only if supported, I think similarly
for various vector widening operations etc.
One option is not to fold into gimple only those builtins where we know it
will not work on generic vectors; my preference is to not fold any builtin
which would be rejected at expansion time, so user get at least consistent
diagnostics. Usually people are using the altivec.h etc. headers that error
if the ISA is not enabled, so this will only affect people that use the
builtins directly.
Bootstrapped/regtested on powerpc64{,le}-linux, ok for trunk?
2017-11-23 Jakub Jelinek <jakub@redhat.com>
PR target/82848
* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Don't fold
builtins not enabled in the currently selected ISA.
--- gcc/config/rs6000/rs6000.c.jj 2017-11-23 10:29:01.000000000 +0100
+++ gcc/config/rs6000/rs6000.c 2017-11-23 10:30:54.930019590 +0100
@@ -16143,6 +16143,12 @@ rs6000_gimple_fold_builtin (gimple_stmt_
if (!gimple_call_lhs (stmt) && !rs6000_builtin_valid_without_lhs (fn_code))
return false;
+ /* Don't fold invalid builtins, let rs6000_expand_builtin diagnose it. */
+ HOST_WIDE_INT mask = rs6000_builtin_info[uns_fncode].mask;
+ bool func_valid_p = (rs6000_builtin_mask & mask) == mask;
+ if (!func_valid_p)
+ return false;
+
switch (fn_code)
{
/* Flavors of vec_add. We deliberately don't expand
--- gcc/testsuite/gcc.target/powerpc/pr82848.c.jj 2017-11-23 10:34:14.670471607 +0100
+++ gcc/testsuite/gcc.target/powerpc/pr82848.c 2017-11-23 10:36:22.754841465 +0100
@@ -0,0 +1,13 @@
+/* PR target/82848 */
+/* { dg-do compile } */
+/* { dg-options "-mno-altivec -mno-vsx -Wno-psabi" } */
+
+#define C 3.68249351546114573519399405666776E-44f
+#define vector __attribute__ ((altivec (vector__)))
+
+vector float
+foo (vector float a)
+{
+ vector float b = __builtin_vec_madd (b, a, (vector float) { C, C, C, C }); /* { dg-error "requires the '-maltivec' option" } */
+ return b;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix powerpc* ICE with vec builtins with -mno-altivec (PR target/82848)
2017-11-23 21:22 [PATCH] Fix powerpc* ICE with vec builtins with -mno-altivec (PR target/82848) Jakub Jelinek
@ 2017-11-25 8:40 ` Segher Boessenkool
0 siblings, 0 replies; 2+ messages in thread
From: Segher Boessenkool @ 2017-11-25 8:40 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: David Edelsohn, Will Schmidt, gcc-patches
Hi Jakub,
On Thu, Nov 23, 2017 at 10:02:24PM +0100, Jakub Jelinek wrote:
> With -mno-altivec -mno-vsx -mno-fold-gimple we error on __builtin_vec*
> builtins used when corresponding ISA is not enabled.
> When folding gimple, in some cases we get away with it (e.g. when folding
> the builtin to PLUS_EXPR on the generic vectors), because
> tree-vect-generic.c lowers those into scalar piecewise operations,
> but e.g. in case of FMA_EXPR tree-vect-generic.c isn't doing anything,
> expects that FMA_EXPR is actually used only if supported, I think similarly
> for various vector widening operations etc.
>
> One option is not to fold into gimple only those builtins where we know it
> will not work on generic vectors; my preference is to not fold any builtin
> which would be rejected at expansion time, so user get at least consistent
> diagnostics. Usually people are using the altivec.h etc. headers that error
> if the ISA is not enabled, so this will only affect people that use the
> builtins directly.
Yeah I agree.
Okay for trunk, thanks!
Segher
> 2017-11-23 Jakub Jelinek <jakub@redhat.com>
>
> PR target/82848
> * config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Don't fold
> builtins not enabled in the currently selected ISA.
(You forgot changelog for the added testcase).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-25 0:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-23 21:22 [PATCH] Fix powerpc* ICE with vec builtins with -mno-altivec (PR target/82848) Jakub Jelinek
2017-11-25 8:40 ` Segher Boessenkool
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).