[LLVMbugs] [Bug 3831] New: miscompilation with loop index splitting and shorts
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Wed Mar 18 04:13:45 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=3831
Summary: miscompilation with loop index splitting and shorts
Product: libraries
Version: 2.5
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: Loop Optimizer
AssignedTo: unassignedbugs at nondot.org
ReportedBy: jay.foad at antixlabs.com
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=2724)
--> (http://llvm.org/bugs/attachment.cgi?id=2724)
source file
With the attached source file I get:
$ llvm-gcc -emit-llvm -c loop.c ; lli loop.o ; echo $?
0
which is correct: f() returns 0 because there is no j in [0..q] such that p + j
== i (with i = 1, q = 2, p = 3).
At -O2 I get:
$ llvm-gcc -O2 -emit-llvm -c loop.c ; lli loop.o ; echo $?
3
which is wrong. The disassembly of f() (inlined into g()) is:
define i32 @g(i16 zeroext %i) nounwind readonly {
entry:
%0 = zext i16 %i to i32 ; <i32> [#uses=2]
%1 = load i32* @q, align 4 ; <i32> [#uses=1]
%lisplit2 = icmp ugt i32 %0, %1 ; <i1> [#uses=1]
br i1 %lisplit2, label %bb2.i, label %bb1.i
bb1.i: ; preds = %entry
%2 = mul i32 %0, 3 ; <i32> [#uses=1]
ret i32 %2
bb2.i: ; preds = %entry
ret i32 0
}
so it's going to return
(unsigned int)i > q ? 0 : (unsigned int)i * 3
This seems wrong because now there is absolutely no mention of p!
I assume, because of the %lisplit2 variable, that this is something to do with
loop index splitting. If I replace "short" with "int" throughout the source
file, the bug goes away.
--
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