[LLVMbugs] [Bug 20732] New: PPC: 64-bit signed integer division by power of 2 isn't optimized into sradi + addze

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 22 11:12:57 PDT 2014


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

            Bug ID: 20732
           Summary: PPC: 64-bit signed integer division by power of 2
                    isn't optimized into sradi + addze
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Using llc built from r216267:

$ cat div.ll
define i64 @foo(i64 %n) {
  %div = sdiv i64 %n, 8
  ret i64 %div
}

$ ./llc -mtriple=powerpc64 div.ll -o -
...
    li 4, 8
    divd 3, 3, 4
    blr

-------------------------------------------------------

I think this can be optimized to:
       sradi 3, 3, 3
    addze 3, 3
    blr



The fix for this bug should model what AArch64TargetLowering::BuildSDIVPow2()
does. PPC should not use "setPow2SDivIsCheap()" to execute the current code in
PPCDAGToDAGISel::Select(). There's a "FIXME" in the code comments about this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140822/6b079b4e/attachment.html>


More information about the llvm-bugs mailing list