[LLVMbugs] [Bug 5313] New: Optimisation "loop-rotate" generate unoptimal dirty code
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Tue Oct 27 04:08:38 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=5313
Summary: Optimisation "loop-rotate" generate unoptimal dirty code
Product: new-bugs
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: code-quality
Severity: minor
Priority: P2
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: quickslyver at free.fr
CC: llvmbugs at cs.uiuc.edu
with this simple function:
$cat test-opt.c
void append_text(const char* text,unsigned char * const io)
{
while(*text)
*io=*text++;
}
-------------------------------------
optimized with loop-rotate:
$clang-cc test-opt.c -O3 -o - -S -triple=thumb-unknown-unknown
(...)
append_text:
ldrb r2, [r0]
cmp r2, #0
beq .LBB1_3
movs r2, #0
.LBB1_2:
ldrb r3, [r0, r2]
strb r3, [r1]
adds r2, r2, #1
ldrb r3, [r0, r2]
cmp r3, #0
bne .LBB1_2
.LBB1_3:
bx lr
.size append_text, .-append_text
-----------------------------------------
Without loop-rotate:
$clang-cc test-opt.c -O0 -o - -emit-llvm-bc -triple=thumb-unknown-unknown | opt
-simplifycfg -domtree -domfrontier -scalarrepl -instcombine -simplifycfg
-globalopt -globaldce -ipconstprop -deadargelim -instcombine -simplifycfg
-basiccg -prune-eh -functionattrs -inline -argpromotion -simplify-libcalls
-instcombine -jump-threading -simplifycfg -domtree -domfrontier -scalarrepl
-instcombine -break-crit-edges -condprop -tailcallelim -simplifycfg
-reassociate -domtree -loops -loopsimplify -domfrontier -loopsimplify -lcssa
-licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loopsimplify -lcssa
-iv-users -loop-deletion -loopsimplify -lcssa -loop-unroll -instcombine -memdep
-gvn -memdep -memcpyopt -sccp -instcombine -break-crit-edges -condprop -domtree
-memdep -dse -adce -simplifycfg -strip-dead-prototypes -print-used-types
-deadtypeelim -constmerge -preverify -domtree -verify | llc -O3
-asm-verbose=false
(...)
.LBB1_1:
ldrb r2, [r0]
cmp r2, #0
beq .LBB1_3
strb r2, [r1]
adds r0, r0, #1
b .LBB1_1
.LBB1_3:
bx lr
--------------------------------------
I target Thumb architecture because I read it easily, but you can directly dump
llvm-ir or others target: It is a problem at llvm-ir optimization stage.
--
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