This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/70251] Wrong code with -O3 -march=skylake-avx512.


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70251

--- Comment #11 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to rguenther@suse.de from comment #10)
> > Unless we start transforming x?-1:0 into
> > view_convert_expr(x) under the same condition (VECTOR_MODE_P(...)), it doesn't
> > make sense to me.
> 
> I think that would be a valid transform.

Ah, ok. I thought it was a deliberate choice (maybe to keep things consistent
between AVX512 and the rest). Vector lowering might also gain a few interesting
cases.

> > (In reply to rguenther@suse.de from comment #5)
> > > On Wed, 16 Mar 2016, glisse at gcc dot gnu.org wrote:
> > > > A + (B vcmp C ? 1 : 0)  ->  A - (B vcmp C ? -1 : 0)
> > > I think that would be an odd transform.
> > 
> > As far as I understand, since the bool vector changes, this is currently the
> > proper gimple syntax for this transformation, with the added bonus that it
> > doesn't need to be disabled for avx512.
> 
> Sure, but nowhere else we transform a + into a - operation(?)  This
> is what I mean with "odd transform".

It is indeed (and we are already performing it).

> We'd get this motivated only
> by (B vcmp C ? -1 : 0) being "canonical" for target expansion, right?

Yes (canonical and cheaper).

> > (I got "incorrect sharing of tree nodes" on the first argument of vec_cond_expr
> > when I wanted to try it out, the match-simplify machinery should probably do
> > the unshare_expr automatically, especially since gimplify now wants to keep the
> > comparison inside the vec_cond_expr)
> 
> Ah, yes, that's sth we need to fix.  Care to share the pattern/testcase
> that triggers this?  The place to fix seems a bit non-obvious.

typedef int vec __attribute__((vector_size(64)));
vec f(vec x,vec y,vec z){
  vec zero={};
  vec one=zero+1;
  vec c=x<y;
  return z+(c?one:zero);
}

g++ a.c -c -O -w -Wno-psabi
a.c: In function 'vec f(vec, vec, vec)':
a.c:7:1: error: incorrect sharing of tree nodes
 }
 ^
x_3(D) < y_4(D)
_1 = VEC_COND_EXPR <x_3(D) < y_4(D), { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }>;
a.c:7:1: internal compiler error: verify_gimple failed
0x10af447 verify_gimple_in_cfg(function*, bool)
        /home/glisse/trunk/gcc/tree-cfg.c:5125
0xf494d0 execute_function_todo
        /home/glisse/trunk/gcc/passes.c:1958
0xf485a3 do_per_function
        /home/glisse/trunk/gcc/passes.c:1645
0xf496ac execute_todo
        /home/glisse/trunk/gcc/passes.c:2010

--- gcc/match.pd        (revision 234381)
+++ gcc/match.pd        (working copy)
@@ -1759,11 +1759,10 @@
 (simplify
  (plus:c @3 (view_convert? (vec_cond @0 integer_each_onep@1 integer_zerop@2)))
  (if (VECTOR_TYPE_P (type)
-      && VECTOR_MODE_P (TYPE_MODE (TREE_TYPE (@0)))
       && TYPE_VECTOR_SUBPARTS (type) == TYPE_VECTOR_SUBPARTS (TREE_TYPE (@0))
       && (TYPE_MODE (TREE_TYPE (type))
           == TYPE_MODE (TREE_TYPE (TREE_TYPE (@0)))))
-  (minus @3 (view_convert @0))))
+  (minus @3 (view_convert (vec_cond @0 (negate @1) @2)))))

 /* ... likewise A - (B vcmp C ? 1 : 0) -> A + (B vcmp C).  */
 (simplify

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]