[LLVMbugs] [Bug 1790] New: Loop ICM: Missed optimization on ctype.h functions

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Nov 11 13:13:19 PST 2007


           Summary: Loop ICM: Missed optimization on ctype.h functions
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: edwintorok at gmail.com
                CC: llvmbugs at cs.uiuc.edu

Created an attachment (id=1213)
 --> (http://llvm.org/bugs/attachment.cgi?id=1213)
C example program

Functions like isspace from <ctype.h> access a constant array returned by

Declaration of __ctype_b_loc is:
extern __const unsigned short int **__ctype_b_loc (void)
     __attribute__ ((__const));

Yet, in the generated llvm bytecode and assembly __ctype_b_loc is called each
(if I call isspace in a loop).
Gcc generates similar code (__ctype_b_loc inside of the loop), but I think llvm
could do better, and optimize this by moving function calls out of loops *iff*
they are "const" functions.

The problem is that in the generated bitcode the constness of __ctype_b_loc is
lost, it is simply an: declare i16** @__ctype_b_loc()

Attached small C example program, preprocessed C, and bitcode.

I didn't do any benchmarks, but I think avoiding an extra call is a win, and
doesn't need a benchmark to prove it ;)

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