[llvm-bugs] [Bug 42382] New: An optimization error about loop unrolling
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 25 04:18:49 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42382
Bug ID: 42382
Summary: An optimization error about loop unrolling
Product: new-bugs
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: witstorm at 163.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
In the experiment, when clang uses O2 and O3 optimization options, the pass of
Loop unrolling will cause an result error.The procedure is as follows:
typedef int A __attribute__((vector _size(64),aligned(64)));
A Aa,Ab,Ai;
static __inline A __attribute__((__always_inline__))
SET_A (int __A,int __B,int __C,int __D,int __E,int __F,int __G,int __H,int
__I,int __J,int __K,int __L,int __M,int __N,int __O,int __P){
union{
int __a[16] __attribute__((aligned(64)));
A __v;
}__u;
__u.__a[0]=__A;
__u.__a[1]=__B;
__u.__a[2]=__C;
__u.__a[3]=__D;
__u.__a[4]=__E;
__u.__a[5]=__F;
__u.__a[6]=__G;
__u.__a[7]=__H;
__u.__a[8]=__I;
__u.__a[9]=__J;
__u.__a[10]=__K;
__u.__a[11]=__L;
__u.__a[12]=__M;
__u.__a[13]=__N;
__u.__a[14]=__O;
__u.__a[15]=__P;
return __u.__v;
}
int main(){
int
r[16]={2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047,2047};
int i;
for(i=1024;i>=1;i>>=1){
Ai=SET_A(i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i);
Aa^=Aa>>i;
Ab+=Aa+Ai;
}
}
You can reproduce the error with the following command:
clang -arch=x86 -static -O2 -emit-llvm -S a.c
Loop unrolling optimization produces incorrect values in IR.
--
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/20190625/389fcbc8/attachment-0001.html>
More information about the llvm-bugs
mailing list