[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


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

             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 =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
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

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

b:
  ret i32 0
}

llc emits

_foo:                                   ## @foo
    .cfi_startproc
## BB#0:
    pushq    %rax
Ltmp1:
    .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
    ret
LBB0_2:                                 ## %b
    xorl    %eax, %eax
    popq    %rdx
    ret


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