[LLVMbugs] [Bug 2235] New: llvm-g++ generates awful code for insertion sort
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sat Apr 19 22:08:18 PDT 2008
http://llvm.org/bugs/show_bug.cgi?id=2235
Summary: llvm-g++ generates awful code for insertion sort
Product: libraries
Version: 2.2
Platform: PC
OS/Version: All
Status: NEW
Keywords: code-quality
Severity: normal
Priority: P2
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: sabre at nondot.org
CC: llvmbugs at cs.uiuc.edu
llvm-g++ -O3 compiles this:
void ins_sort(double *end, double *begin) {
double *p = begin;
++p;
while (p != end) {
double tmp = *p;
double *j = p;
double *prev = j;
for ( ; j != begin && tmp < *--prev; --j )
*j = *prev;
*j = tmp;
++p;
}
}
into some horrible code that includes:
LBB1_7: ## bb19.bb30_crit_edge
xorb %bl, %bl
LBB1_8: ## bb30
notb %bl
testb $1, %bl
jne LBB1_5 ## bb8
This comes from this block:
bb30: ; preds = %bb19, %bb29
%j.0.reg2mem.2 = phi double* [ %j.0.reg2mem.1, %bb29 ], [
%j.0.reg2mem.0, %bb19 ] ; <double*> [#uses=3]
%prev.1 = phi double* [ %prev.0, %bb29 ], [ %tmp21, %bb19 ]
; <double*> [#uses=3]
%iftmp.1.0 = phi i1 [ true, %bb29 ], [ false, %bb19 ] ; <i1>
[#uses=1]
br i1 %iftmp.1.0, label %bb34, label %bb8
I will work on simplifycfg to try to eliminate this. One odd thing is that we
generate reasonable code with llvm-gcc, but not llvm-g++.
--
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