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: unassignedclangb...@nondot.org
          Reporter: denis.yaroshevs...@gmail.com
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to