[llvm-bugs] [Bug 25139] New: Loop vectorization stops working because of pointer bitcast

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Oct 11 15:38:01 PDT 2015


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

            Bug ID: 25139
           Summary: Loop vectorization stops working because of pointer
                    bitcast
           Product: libraries
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: yyc1992 at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 15048
  --> https://llvm.org/bugs/attachment.cgi?id=15048&action=edit
c repro

I first noticed this issue in the following julia code

```
fill_simd(A, v) = @inbounds @simd for i in eachindex(A)
    A[i] = v[1]
end
```

The loop failed to be vectorized if `v` is a tuple of the same type with the
elements in `A` but successfully vectorize if the two types are different.

The corresponding c repro is

```
void
fill_simd1(float *__restrict__ A, size_t size, const float *__restrict__ v)
{
    for (size_t i = 0;i < size;i++) {
        A[i] = *v;
    }
}
```

When compiling with clang, the vectorization fails for the function above but
succeed if any of the `float` is replaced with `double`.

With llvm debug output in the julia version, it seems that the reason
vectorization fails is that the vectorizer is expecting a `getelementptr`
instruction as the load address but see a `bitcast` instruction instead.
Relavant llvm ir output,

```
  %6 = getelementptr inbounds float, float* %A, i64 %i.01.prol
  %7 = bitcast float* %6 to i32*
  store i32 %3, i32* %7, align 4, !tbaa !1
```

Such instruction doesn't exist when compiling with LLVM 3.6.2 (julia version)
and the vectorization succeed so somehow some llvm passes is inserting it and
this is an regression in 3.7...

The repro scripts can all be found at
https://github.com/yuyichao/explore/tree/66a6d368aa5e9dbfc44ad15135296bbbe9f26603/julia/simd_fill
I'll also attach them to the bug report later (couldn't figure out how to
attach multiple files at once)

-- 
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/20151011/adb37905/attachment.html>


More information about the llvm-bugs mailing list