[LLVMbugs] [Bug 10614] New: Redundant load of address of array

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 8 22:11:16 PDT 2011


           Summary: Redundant load of address of array
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jmuizelaar at mozilla.com
                CC: llvmbugs at cs.uiuc.edu

The following code produces some a redundant leaq of the address of the array

#include <stdint.h>
static unsigned int const PowersOf10[] = 
{0, 1, 10, 100, 1000, 10000, 100000,
                1000000, 10000000, 100000000, 1000000000};
uint32_t BiggestPowerTen(uint32_t number,
                            unsigned int number_bits)
  unsigned int t = (number_bits);
  if (number<PowersOf10[t]) {
    return PowersOf10[t];
  } else {
    return PowersOf10[t];

        movl    %esi, %eax
        leaq    __ZL10PowersOf10(%rip), %rcx
        movl    (%rcx,%rax,4), %eax
        cmpl    %edi, %eax
        jbe     LBB0_2

        decl    %esi
        leaq    __ZL10PowersOf10(%rip), %rax
# we could just reuse $rcx here.
        movl    (%rax,%rsi,4), %eax
LBB0_2:                                 ## %return

gcc-4.2 does not have this problem.

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