http://llvm.org/bugs/show_bug.cgi?id=10873
Summary: clang messes up dependence, improperly moves load past
use
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
I believe I've found a bug in clang/llvm on a sandy bridge CPU. I am using
the svn version of clang downloaded Sep 03, 2011:
>sb4>clang -v
>clang version 3.0 (trunk 139049)
>Target: x86_64-unknown-linux-gnu
>Thread model: posix
Take this piece of code:
*******************************************************************************
void ATL_UGEMV(const int M, const int N, const double *A, const int lda,
const double *X, double *Y)
/*
* y = [0,1]*y + A*x, A is MxN, storing the transpose of the matrix
*/
{
double ry, iy;
const int lda2 = lda+lda;
int j;
void dotu_sub(const int, const double*, const int, const double*,
const int, double *);
for (j=0; j < N; j++, A += lda2, Y += 2)
{
ry = *Y; iy = Y[1];
dotu_sub(M, A, 1, X, 1, Y);
*Y += ry;
Y[1] += iy;
}
}
*******************************************************************************
If you compile with
clang -fomit-frame-pointer -mavx -O2 -m64 -S
I believe you will find that clang waits until *after* the subroutine call
to load the values, at which point they have been overwritten by the call.
In order to get clang to produce the right answer, you must rewrite
the loop in this way:
for (j=0; j < N; j++, A += lda2, Y += 2)
{
double dot[2]
dotu_sub(M, A, 1, X, 1, dot);
*Y += dot[0];
Y[1] += dot[1];
}
Thanks,
Clint
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs