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

            Bug ID: 103999
           Summary: Vectorizer failed to reduce sum with conversion.
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---

Vectorizer failed for sum_reduce_cd, but ok for sum_reduce/sum_reduce_cint

float sum_reduce_cd (int n, float* array)
{
    float ans = 0.0f, x;
    for (int i = 0; i != n; i++)
      {
          x = array[i];
          ans += x + 1.0;
      }
    return ans;
}

float sum_reduce (int n, float* array)
{
    float ans = 0.0f, x;
    for (int i = 0; i != n; i++)
      {
          x = array[i];
          ans += x + 1.0f;
      }
    return ans;
}

float sum_reduce_cint (int n, float* array)
{
    int ans = 0;
    float x;
    for (int i = 0; i != n; i++)
      {
          x = array[i];
          ans += (int)(x + 1.0);
      }
    return ans;
}

https://godbolt.org/z/q3McP6d15

Reply via email to