[LLVMbugs] [Bug 110] New: [instcombine] cast-sub-cast -> cast-add miscompiles openssh
bugzilla-daemon at zion.cs.uiuc.edu
bugzilla-daemon at zion.cs.uiuc.edu
Tue Nov 11 23:30:42 PST 2003
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=110
Summary: [instcombine] cast-sub-cast -> cast-add miscompiles
openssh
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: critical
Priority: P2
Component: Scalar Optimizations
AssignedTo: sabre at nondot.org
ReportedBy: gaeke+bugs at uiuc.edu
I narrowed down the miscompilation of openssh to a single function, which
bugpoint most helpfully reduced to the instcombine pass. (I don't know what was
going on before when I thought I was using llvm-as instead of gccas. But anyway.)
I will attach the bytecode for the test program, which is supposed to output
"0x0\n". This particular zero is supposed to be the input to a kind of
shift-register-like thing, so if you get that first byte wrong, the subsequent
bytes have no hope.
The before-and-after diffs are pretty stark... instcombine has replaced my usual
tasty pointer arithmetic with something which is definitely much worse than
Folgers Crystals.
445 zion> diff -u testprogramE.unopt.ll testprogramE.opt.ll
--- testprogramE.unopt.ll 2003-11-12 01:22:43.000000000 -0600
+++ testprogramE.opt.ll 2003-11-12 01:23:08.000000000 -0600
@@ -26,9 +26,8 @@
%tmp.7 = cast sbyte %tmp.6 to int ; <int> [#uses=1]
%tmp.3 = call sbyte* %strchr( sbyte* getelementptr ([4 x sbyte]*
%.Base64_1, long 0, long 0), int %tmp.7 ) ; <sbyte*> [#uses=1]
%tmp.8 = cast sbyte* %tmp.3 to int ; <int> [#uses=1]
- %tmp.9 = cast int %tmp.8 to sbyte ; <sbyte> [#uses=1]
- %tmp.12 = sub sbyte %tmp.9, cast ([4 x sbyte]* %.Base64_1 to sbyte)
; <sbyte> [#uses=1]
- %tmp.13 = cast sbyte %tmp.12 to ubyte ; <ubyte> [#uses=1]
+ %tmp.9 = cast int %tmp.8 to ubyte ; <ubyte> [#uses=1]
+ %tmp.13 = add ubyte %tmp.9, 9 ; <ubyte> [#uses=1]
%tmp.14 = shl ubyte %tmp.13, ubyte 2 ; <ubyte> [#uses=1]
%tmp.15 = cast ubyte %tmp.14 to int ; <int> [#uses=1]
%tmp.1 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([6 x
sbyte]* %.str_2, long 0, long 0), int %tmp.15 ) ; <int> [#uses=0]
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list