[llvm-dev] Possible AVX512 codegen bug in LLVM 10.0.1?
TB Schardl via llvm-dev
llvm-dev at lists.llvm.org
Fri Sep 4 20:49:39 PDT 2020
Hey LLVMDev,
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.
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.)
The crux seems to be that the recursive function, _Z7loopdacllPjl, 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 _Z7loopdacllPjl
loads this vector argument off the stack with a 64-byte reload (notably on
line 78). But before the call to _Z7loopdacllPjl 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 _Z7loopdacllPjl gets a vector
half-filled with garbage values, leading to the observed misbehavior.
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?
Please let me know if there's any other information you need from me.
Cheers,
TB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200904/53671b02/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avx512_codegen_bug.ll
Type: application/octet-stream
Size: 40283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200904/53671b02/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avx512_codegen_bug.s
Type: application/octet-stream
Size: 32126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200904/53671b02/attachment-0003.obj>
More information about the llvm-dev
mailing list