[llvm-bugs] [Bug 30502] New: AVX512: incorrect code generation for simple piece of code (KNL & CNL backends affected)
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 23 02:05:43 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=30502
Bug ID: 30502
Summary: AVX512: incorrect code generation for simple piece of
code (KNL & CNL backends affected)
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: wenzel.jakob at epfl.ch
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
I've run into issues where the current (trunk) backend for Xeon Phi generates
incorrect code. As with similar issues before, it's got something to do with
LLVM's use of mask registers.
The snippet is given below (I tried to make it as small as possible). It makes
no use of AVX512 features whatsoever.
Try it as follows:
$ clang++ -march=nocona -std=c++11 -stdlib=libc++ -O0 -fno-rtti -fno-exceptions
-o test_works
$ ./test_works
(no crash)
$ clang++ -march=knl -std=c++11 -stdlib=libc++ -O0 -fno-rtti -fno-exceptions -o
test_broken
$ ./test_broken
[2] 91952 segmentation fault (core dumped) ./test_broken
Looking at the diff of the assembly files generated by the two different
backends, there is only one change which is not equivalent and thus introduces
the failure:
$ diff -u assembly-nocona.s assembly-knl.s [INS]
--- assembly-nocona.s 2016-09-23 11:09:30.000000000 +0200
+++ assembly-knl.s 2016-09-23 11:09:30.000000000 +0200
@@ -66,7 +66,8 @@
movq %rax, -24(%rbp) # 8-byte Spill
callq _ZN5ArrayC2Ev
movb $1, -1(%rbp)
- testb $1, -1(%rbp)
+ movb -1(%rbp), %cl
+ kortestw %cl, %cl
jne .LBB1_2
# BB#1:
movq -16(%rbp), %rdi # 8-byte Reload
=========================================
#include <memory>
/* Some dummy data structure */
struct Data { float f; };
/* Stores a 'Data' instance via unique_ptr */
struct Array {
using Holder = std::unique_ptr<Data[]>;
Array() : data(new Data[1]) { }
Array(const Array &) : data(new Data[1]) { }
static Array Make() { Array result; return result; }
Array &operator=(Array &value) { data[0] = value.data[0]; return *this; }
Holder data;
};
int main(int /* argc */, char * /* argv */[]) {
Array a = Array::Make();
/* This next line causes a crash (nullptr dereference in __memcpy) */
Data result = a.data[0];
/* Quench unused variable warning */
(void) result;
return 0;
}
===========================
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160923/089e0a75/attachment.html>
More information about the llvm-bugs
mailing list