[llvm-bugs] [Bug 44318] New: Missed Store forwarding optimization as the Alias analysis failed to establish "noalias" information.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 17 01:22:49 PST 2019


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

            Bug ID: 44318
           Summary: Missed Store forwarding optimization as the Alias
                    analysis failed to establish "noalias" information.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: venkataramanan.kumar.llvm at gmail.com
                CC: llvm-bugs at lists.llvm.org

Please consider the following test case.

---Snip--
struct B {
   int b1;
   int b2;
 };

 struct C {
  int b1;
 };

 struct A {
  int a1;
  struct C SC;
  int a2;
 };

 int foo1(struct A * Aptr, struct B* Bptr)
 {
    int *a = &Aptr->SC.b1;
    *a=10;
    Bptr->b1 = 11;
    return *a;
 }

 int foo2(struct A * Aptr, struct B* Bptr)
 {
    Aptr->SC.b1=10;
    Bptr->b1 = 11;
    return Aptr->SC.b1;
}
---Snip--

For the function "foo1" return value is 10 and can be forwarded directly. 
The alias analysis is not able establish the fact that memory accessed by "*a" 
and "Bptr->b1" donot alias each other. 
Hence the optimization is missed.  There is no TBAA information formed for
"&Aptr->SC.b1" and we are not able to prove "noalias" using TBAA.

But for the function "foo2", the Alias analysis proved that "Aptr->SC.b1" and
"Bptr->b1" donot alias each other. TBAA has proper metadata for both the memory
accesses in this case. Here the return value is forwarded.

-- 
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/20191217/74eae60f/attachment-0001.html>


More information about the llvm-bugs mailing list