<div dir="ltr">Hey LLVMDev,<div><br></div><div>Perhaps I'm missing something, but I think I've stumbled across a codegen bug in LLVM 10.0.1 related to AVX512.  I've attached a small LLVM IR testcase and generated x86_64 assembly file that shows the bug.</div><div><br></div><div>The test case is small, but not quite minimal, mostly because of driver code included in the test case so one can compile and run the program.  The program does a simple vectorizable computation two ways — once with a vectorized loop, and then with a recursive function that contains a vectorized loop at its base case — and then compares the results of those two computations.  If it behaves correctly, both computations should produce the same result, and the program should produce no output.  But right now it seems that the recursive-function version produces roughly half incorrect results, in a repeating pattern of 4 correct results followed by 4 incorrect results.  (There are also some commented-out lines in the LLVM file, from my own testing of alternative implementations to confirm that the recurisve-function code is otherwise correct.)</div><div><br></div><div>The crux seems to be that the recursive function, <font face="monospace">_Z7loopdacllPjl</font>, takes a vector of 8 64-bit integers as one of its arguments.  There's no issue with such an argument in LLVM IR, but the generated assembly seems to be incorrect.  Examining the assembly file, it seems that <font face="monospace">_Z7loopdacllPjl</font> loads this vector argument off the stack with a 64-byte reload (notably on line 78).  But before the call to <font face="monospace">_Z7loopdacllPjl</font> from main (line 595), I only see a single 32-byte spill corresponding to this vector argument.  Hence, it seems that the vectorized loop in <font face="monospace">_Z7loopdacllPjl</font> gets a vector half-filled with garbage values, leading to the observed misbehavior.</div><div><br></div><div>I'm not familiar enough with LLVM's x86_64 backend to understand why it generates this particular assembly.  But the generated assembly seems incorrect to me.  Am I missing something?</div><div><br></div><div>Please let me know if there's any other information you need from me.</div><div><br></div><div>Cheers,</div><div>TB</div></div>