[llvm-bugs] [Bug 46319] New: LLVM does not see that two writes are independent.

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 14 08:33:23 PDT 2020


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

            Bug ID: 46319
           Summary: LLVM does not see that two writes are independent.
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: denis.yaroshevskij at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

See this part of a simd optimized routine that doubles every element in an
array.

https://godbolt.org/z/SLp3Ec

Even though clang can in both cases successfully see that all 4 reads are
independent:

```
        vmovdqa ymm0, ymmword ptr [rdi]
        vmovdqa ymm1, ymmword ptr [rdi + 32]
        vmovdqa ymm2, ymmword ptr [rdi + 64]
        vmovdqa ymm3, ymmword ptr [rdi + 96]
```

It introduces dependencies between independent computations by default:

```
        vpaddd  ymm0, ymm0, ymm0
        vmovdqa ymmword ptr [rdi], ymm0
        vpaddd  ymm0, ymm1, ymm1
        vmovdqa ymmword ptr [rdi + 32], ymm0
        ...
```

While I suspect it should be just `loads, adds, stores`

This is also what clang generates when auto-vectorizing this:
https://godbolt.org/z/ik55Yv

NOTE: on my measurements hacking around this didn't have an effect, probably
the processor could figure it out on it's own. However, this is not ideal and I
can imagine you can encounter a situation when this will backfire.

-- 
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/20200614/9cf3c868/attachment.html>


More information about the llvm-bugs mailing list