[LLVMbugs] [Bug 1909] New: Serious tail merging pessimization

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Jan 12 11:52:21 PST 2008


http://llvm.org/bugs/show_bug.cgi?id=1909

           Summary: Serious tail merging pessimization
           Product: libraries
           Version: 2.1
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: code-quality
          Severity: normal
          Priority: P2
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sabre at nondot.org
                CC: dalej at apple.com, llvmbugs at cs.uiuc.edu


Consider:

#include <stdio.h>
#include <stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
void minmax(float result[8]) {
 float min_x, max_x, min_y, max_y;

 min_x = MIN(result[0], MIN(result[2], MIN(result[4], result[6])));
 max_x = MAX(result[0], MAX(result[2], MAX(result[4], result[6])));
 min_y = MIN(result[1], MIN(result[3], MIN(result[5], result[7])));
 max_y = MAX(result[1], MAX(result[3], MAX(result[5], result[7])));

 printf("transformed bounds: (%.2f, %.2f), (%.2f, %.2f)\n", min_x, min_y,
max_x, max_y);
}

Without tail merging, we get ugly code.  With tail merging, we get aweful code
:)  It seems to be merging lots of "single instructions", yielding code like
this:

LBB1_53:        # bb
        ucomiss %xmm3, %xmm1
        jmp     LBB1_2  # bb21
LBB1_54:        # bb128
        ucomiss %xmm1, %xmm3
        jmp     LBB1_15 # bb136
LBB1_55:        # bb243
        ucomiss %xmm3, %xmm1
        jmp     LBB1_28 # bb251
LBB1_56:        # bb358
        ucomiss %xmm1, %xmm3
        jmp     LBB1_41 # bb366
LBB1_57:        # bb395
        ucomiss %xmm0, %xmm2
        jmp     LBB1_44 # bb385
LBB1_58:        # bb425.bb456_crit_edge
        movl    %edi, %eax
        jmp     LBB1_52 # bb456
...

at the end of the function.  If this is what is happening, it should be fixed. 
Saving a single instruction isn't worthwhile because we have to add the jump,
and this makes code potentially slower.


-- 
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