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

Robin Dapp <rdapp at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rdapp at gcc dot gnu.org

--- Comment #1 from Robin Dapp <rdapp at gcc dot gnu.org> ---
Interesting, that's a good catch.
Looks like we use the wrong second operand in the outer gather/permute:

    e = __builtin_shufflevector(
          ~__builtin_shufflevector(bla, e, 1, 4, 3, 4), e, 0, 1, 1, 7);

  vnot.v        v2,v2                  # ~__builtin_shufflevector((a){}, e, 1,
4, 3, 4)
  vrgather.vv   v1,v2,v4               # shuffle < 4 indices of {0, 1, 1, 7}
into v1
  vmv1r.v       v0,v7
  vmv1r.v       v2,v1
  vrgather.vv   v1,v2,v6,v0.t          # shuffle >= 4 indices of {0, 1, 1, 7}
into v1

v2 (= v1) is wrong in the second gather.  We don't want to select indices from
the first shuffle but from e here.  e1 already resides in v1 and we want to
overwrite it.

However, during expansion of this two-source permute we overwrite v1 in the
first gather already (when it only holds an intermediate result) and then
erroneously use v1 as source again.  That can be fixed by not using the target
rtx directly but a temporary.  Testing a simple patch.

Reply via email to