[LLVMbugs] [Bug 6394] New: Optimizer swaps bitcast and getelementptr in an invalid way
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Feb 22 13:48:45 PST 2010
http://llvm.org/bugs/show_bug.cgi?id=6394
Summary: Optimizer swaps bitcast and getelementptr in an
invalid way
Product: libraries
Version: 2.6
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P5
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: llvm at henning-thielemann.de
CC: llvmbugs at cs.uiuc.edu
Estimated Hours: 0.0
I have written a custom malloc and free for vector aligned data, because as far
as I can see, the C interface to LLVM does not provide an alignment parameter
for malloc and without that, malloc does not choose 16 byte alignment for
vectors.
Anyway the following issue is certainly a bug.
Consider the custom free routine that I have written:
%wrap = type { float, <4 x float>* }
define void @_myfree(float*) {
_L1:
%1 = bitcast float* %0 to %wrap*
%2 = getelementptr %wrap* %1, i32 0, i32 1
%3 = load <4 x float>** %2
free <4 x float>* %3
ret void
}
It is compiled to
movl 8(%esp), %eax
movl 4(%eax), %eax
movl %eax, (%esp)
call free
However, if I run optimization (opt -O1) I obtain
define void @_myfree(float* nocapture) nounwind {
_L1:
%1 = getelementptr float* %0, i64 2 ; <float*> [#uses=1]
%2 = bitcast float* %1 to <4 x float>** ; <<4 x float>**> [#uses=1]
%3 = load <4 x float>** %2 ; <<4 x float>*> [#uses=1]
free <4 x float>* %3
ret void
}
which is compiled to
movl 8(%esp), %eax
movl 8(%eax), %eax
movl %eax, (%esp)
call free
which is certainly wrong. (See the differing displacement for (%eax).)
--
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.
More information about the llvm-bugs
mailing list