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

            Bug ID: 100499
           Summary: Different results with -fpeel-loops
                    -ftree-loop-vectorize options
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dongjianqiang2 at huawei dot com
  Target Milestone: ---

cat demo.c
#include<stdio.h>
typedef unsigned short uint16_t;
typedef signed int int32_t;
static uint16_t g_2823 = 0xEC75L;
static uint16_t g_116 = 0xBC07L;

static uint16_t
(safe_mul_func_uint16_t_u_u)(uint16_t ui1, uint16_t ui2 )
{

  return ((unsigned int)ui1) * ((unsigned int)ui2);
}

int main (int argc, char* argv[])
{
    uint16_t l_2815 = 65535UL;
    uint16_t *l_2821 = &g_116;
    uint16_t *l_2822 = &g_2823;

    printf ("start g_2823 = %d\n", g_2823);
lbl_2826:
    l_2815 &= 0x9DEF1EAEL;
    if (+(safe_mul_func_uint16_t_u_u(((*l_2821) = l_2815), (--(*l_2822)))))
    {
      goto lbl_2826;
    }
    printf ("end g_2823 = %d\n", g_2823);

    return 0;
}

Compiling with 

gcc demo.c -O1
./a.out
start g_2823 = 60533
end g_2823 = 32768

gcc demo.c -O1 -fpeel-loops -ftree-loop-vectorize
./a.out
start g_2823 = 60533
end g_2823 = 60526

gives different results

Reply via email to