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

            Bug ID: 95401
           Summary: GCC produces incorrect instruction with -O3 for
                    skylake-avx512
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vsevolod.livinskij at frtk dot ru
  Target Milestone: ---

GCC produces incorrect instruction with -O3 for skylake-avx512 (also for
icelake-server and tigerlake).

Error:
>$ g++ -O3 func.cpp driver.cpp -march=skylake-avx512 && sde -skx -- ./a.out 
SDE ERROR:  TID: 0 executed instruction with an unaligned memory reference to
address 0x404064 INSTR: 0x000401201: IFORM: VMOVDQA_MEMdq_XMMdq :: vmovdqa
xmmword ptr [rcx*4+0x404060], xmm0
        IMAGE:   
/home/vlivinsk/workspace/yarpgen/bugs/may-28/gcc-miscompile/reduce/a.out
        FUNCTION: _Z4testv
        FUNCTION ADDR: 0x000401120

Reproducer:
driver.cpp
int var_9 = 1693986256, var_14;
int arr_16[11];
void test();
int main() { test(); }

func.cpp
extern int var_9;
extern unsigned var_14;
extern int arr_16[];
#include <algorithm>
void test() {
  for (short a = 0; a < (short)var_9; a += 12140)
    for (short b = 0; b < 8; b++)
      if (std::max(var_14, 1U))
        arr_16[a + b] = 0;
}

GCC version: 11.0.0 (5c715e6a2990cfb6c15acc1ee14219523534ec69)

Reply via email to