[LLVMbugs] [Bug 13578] New: MachineCSE doesn't eliminate duplicate GOTPCREL loads

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Aug 11 03:49:41 PDT 2012


             Bug #: 13578
           Summary: MachineCSE doesn't eliminate duplicate GOTPCREL loads
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: benny.kra at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 9035
  --> http://llvm.org/bugs/attachment.cgi?id=9035
reduced test case

For this reduced test case

target datalayout =
target triple = "x86_64-apple-macosx10.8.0"

@glob = external global i32

declare i1 @x()

define i32 @foo() {
  store i32 42, i32* @glob
  %c = call i1 @x()
  br i1 %c, label %a, label %b

  %l = load i32* @glob
  ret i32 %l

  ret i32 0

llc emits

_foo:                                   ## @foo
## BB#0:
    pushq    %rax
    .cfi_def_cfa_offset 16
    movq    _glob at GOTPCREL(%rip), %rax
    movl    $42, (%rax)
    callq    _x
    testb    $1, %al
    je    LBB0_2
## BB#1:                                ## %a
    movq    _glob at GOTPCREL(%rip), %rax
    movl    (%rax), %eax
    popq    %rdx
LBB0_2:                                 ## %b
    xorl    %eax, %eax
    popq    %rdx

The second PCREL load is redundant. Looks like MachineCSE doesn't know that
%rip can't be clobbered.

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