[llvm-bugs] [Bug 30316] New: [ppc] slow instructions caused by unnecessary st/ld forwarding

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 7 14:31:44 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=30316

            Bug ID: 30316
           Summary: [ppc] slow instructions caused by unnecessary st/ld
                    forwarding
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: carrot at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The source code is

class C{
public:
  C();

  bool Next() {
    ++current;
    return !Done();
  }

  bool Done() const { return current >= num; }
  int val() const { return vals[current];}

  int* vals;
  int current;
  int num;
};

int bar() {
  C c;

  int s = 0;
  while (c.Next())
      s |= c.val();
  return s;
}


While compiled with options 
--target=powerpc64le-grtev4-linux-gnu -m64 -O2 -mvsx -mcpu=power8

The while loop is translated to:

.LBB0_2:                                # %while.body
                                        # =>This Inner Loop Header: Depth=1
        extsw 7, 3
        addi 3, 4, 1              // ++current
        sldi 11, 7, 2
        lwzx 7, 6, 11
        stw 3, 112(31)            // store current
        ori 2, 2, 0
        ld 4, 112(31)             // load both current and num
        or 5, 7, 5
        rldicl 12, 4, 32, 32      // extract num
        cmpw 0, 4, 12
        blt      0, .LBB0_2

The interesting part is the code from c.Next(), after the variable current
stored to memory, it is immediately loaded together with another var num in one
load instruction. It triggers the slow store forwarding, or even slower than
store forwarding, since only partial value of the load is in store queue,
another part of the load is in cache.

Actually the value current is already in register 3, it doesn't need to be
loaded again.

-- 
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/20160907/fe526103/attachment.html>


More information about the llvm-bugs mailing list