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

            Bug ID: 122234
           Summary: attribute assume should unroll loops
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manu at gcc dot gnu.org
  Target Milestone: ---

I think GCC should generate the same code for these two functions when
compiling  with -O3 -march=x86-64-v3 

```
double
one_point_hv(const double * restrict x, const double * restrict ref, unsigned
char d)
{
    __attribute__((assume(d > 4)));
    double hv = ref[0] - x[0];
    for (unsigned char i = 1; i < d; i++)
        hv *= (ref[i] - x[i]);
    return hv;
}


double
one_point_hv_2(const double * restrict x, const double * restrict ref, unsigned
char d)
{
    double hv = (ref[0] - x[0])*(ref[1] - x[1])*(ref[2] - x[2])*(ref[3] -
x[3])*(ref[4] - x[4]);
    for (unsigned char i = 5; i < d; i++)
        hv *= (ref[i] - x[i]);
    return hv;
}
```

But it doesn't. 

Another issue is that the vectorizer cannot handle this loop:

<source>:7:33: missed: couldn't vectorize loop
<source>:8:19: missed: not vectorized: no vectype for stmt: _6 = *_5;
 scalar_type: const double
<source>:17:33: missed: couldn't vectorize loop
<source>:18:19: missed: not vectorized: no vectype for stmt: _22 = *_21;
 scalar_type: const double

But that is a different problem.

Reply via email to