[llvm-bugs] [Bug 39186] New: Missed store-load forwarding due to asymmetric alias information

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 5 02:15:11 PDT 2018


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

            Bug ID: 39186
           Summary: Missed store-load forwarding due to asymmetric alias
                    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: jeroen.dobbelaere at synopsys.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20966
  --> https://bugs.llvm.org/attachment.cgi?id=20966&action=edit
test.c showing two similar cases, one that gets optimized, one that doesn't

The attached testcase results in following asymmetric alias relationship
between two stores and one load.
(A) store 42, %0
(B) store 43, %1
(C) load %0

for FOO:
(A)-(B): may alias
(A)-(C): must alias
(B)-(C): no alias (due to __restrict)

for BAR:
(A)-(B): no alias (due to __restrict)
(A)-(C): must alias
(B)-(C): may alias

Content after inlining:

case 'FOO':
  *** IR Dump After Function Integration/Inlining ***
  ; Function Attrs: nounwind uwtable
  define dso_local i32 @foo(i32*, i32*) local_unnamed_addr #0 {
    store i32 42, i32* %0, align 4, !tbaa !2
    store i32 43, i32* %1, align 4, !tbaa !2, !noalias !6
    %3 = load i32, i32* %0, align 4, !tbaa !2, !alias.scope !6
    ret i32 %3
  }

case 'BAR':
  *** IR Dump After Function Integration/Inlining ***
  ; Function Attrs: nounwind uwtable
  define dso_local i32 @bar(i32*, i32*) local_unnamed_addr #2 {
    store i32 42, i32* %0, align 4, !tbaa !2, !alias.scope !6
    store i32 43, i32* %1, align 4, !tbaa !2, !noalias !6
    %3 = load i32, i32* %0, align 4, !tbaa !2
    ret i32 %3
  }

- EarlyCSE is able to optimize foo and see that the load is not necessary.
- EarlyCSE, GVN and NewGVN are not able to optimize bar.

NOTE: gcc is able to optimize both cases

-- 
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/20181005/1e5f55da/attachment.html>


More information about the llvm-bugs mailing list