[LLVMbugs] [Bug 5959] New: Results obtained from an asm volatile corrupted by optimiser
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Wed Jan 6 08:18:20 PST 2010
http://llvm.org/bugs/show_bug.cgi?id=5959
Summary: Results obtained from an asm volatile corrupted by
optimiser
Product: libraries
Version: 2.6
Platform: All
OS/Version: All
Status: NEW
Keywords: miscompilation
Severity: major
Priority: P2
Component: Loop Optimizer
AssignedTo: unassignedbugs at nondot.org
ReportedBy: mark.i.r.muir at gmail.com
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=4007)
--> (http://llvm.org/bugs/attachment.cgi?id=4007)
Test case demonstrating the problem
When inline assembly appears inside a loop, where the result is intentionally
delayed into a later iteration (e.g. to form a shift chain), the optimiser
incorrectly eliminates the delay elements, resulting in corruption.
This seems to affect all back-ends (the attached example demonstrates it on at
least X86 and PPC). The code pattern exhibiting the bug - a shift chain - is
rather contrived for regular microprocessors, but is an important construct for
highly parallel data-path architectures, for efficiently loading-in streams of
data into registers. They achieve the same thing as the following on a regular
microprocessor architecture:
for (i = 0; i < n; i ++)
value[i] = stream_get(i);
where stream_get(i) would be inline assembly reading the nth item from the
stream. The shift chain construct allows value[] to be an array of registers,
initialised from a single loop, with only one instance of the inline assembly
in the loop body.
The problem is visible with -O1 from either clang or llvm-gcc, where the loop
remains intact, but the shift chain is optimised away.
With -O2 however, the loop is unrolled, and the program behaves correctly.
See attached source code for an example.
Thanks.
--
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