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

            Bug ID: 115571
           Summary: `cmp * float` vs `tmp_bool * float` and better
                    vectorization for `cmp * float`
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
void f(float *c, int *a)
{
  for (int i = 0; i < 1024; i++)
  {
    bool t = a[i] == 10;
    c[i] = t * c[i];
  }
}

void f1(float *c, int *a)
{
  for (int i = 0; i < 1024; i++)
  {
    c[i] = (a[i] == 10) * c[i];
  }
}
```

The second one is vectorized better than the first one at -Ofast due to the
second one being converted into `(a[i] == 10) ? c : 0` in fold before
gimplification.

This was inspired by https://github.com/llvm/llvm-project/pull/96216 .

Reply via email to