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

--- Comment #2 from Jennifer Schmitz <jschmitz at gcc dot gnu.org> ---
Thanks for catching this.
Both svbrka and svbrkb produce wrong code with _m predication. Same for
svpmov_lane with _m and a pfalse predicate.
The problem for svbrka/b is that they get folded by the code intended to fold
non-unary function shapes with pfalse predicate, because the inactive operand
happens to be a pfalse in the lines I marked.
svpmov_lane on the other hand gets folded by the code intended for unary
shapes:

gimple *
gimple_folder::fold_pfalse ()
{
  if (pred == PRED_none)
    return nullptr;
  tree arg0 = gimple_call_arg (call, 0);
  if (pred == PRED_m)
    {
      /* Unary function shapes with _m predication are folded to the
         inactive vector (arg0), while other function shapes are folded
         to op1 (arg1).  */
      tree arg1 = gimple_call_arg (call, 1);
      if (is_pfalse (arg1))         // <----- svpmov_lane gets folded HERE
        return fold_call_to (arg0); // <----- svpmov_lane gets folded HERE
      if (is_pfalse (arg0))         // <----- svbrka/b get folded HERE
        return fold_call_to (arg1); // <----- svbrka/b get folded HERE
      return nullptr;
    }
  ...
  return nullptr;
}

For svbrka/b, the pfalse folding should not apply in the test case you gave,
because the predicate is a svptrue.
For svpmov_lane, the pfalse folding is not applicable because the predicate has
a different role.
So, I was thinking of separating the issue into 2 patches: 1. prevent the
inappropriate pfalse folding of svbrka/b (in the case of a pfalse inactive
operand) and svpmov_lane (for a pfalse predicate); and 2. for svbrka/b, add
folding to pfalse in case predicate and operand are ptrue in the svbrk gimple
folder.

Do you agree?

Reply via email to