karrenberg/whole-function-vectorization — Issue #19: Varying pointer arguments are not handled correctly when forced to split.
Author: karrenberg
Created: 2012-01-26 22:41:17+00:00
State: open

In the following example, A is currently marked as "SPLIT_REPLICATE" because it is a pointer argument.
The call to "UnknownFun" requires splitting (SPLIT_FULL) and therefore in turn requires A to be split as well - replication, however, is incorrect here because the scalar prints expect a pointer-to-scalar value instead of the pointer-to-vector value A1 has after vectorization.

```
define void @test(%"STR"* noalias nocapture %A) nounwind {
entry:
call void @UnknownFun(%"STR"* %A)
ret void
}
```

What should happen is that W objects of the scalar type STR are allocated on the stack, A is loaded, the underlying object is split into W scalar objects that are stored to the allocated memory, and the pointers to this memory are given to the resulting scalar calls.

```
define void @test_4(%"STR_4"* noalias nocapture %A) nounwind {
entry:
%A_0 = alloca %"STR"
%A_1 = alloca %"STR"
%A_2 = alloca %"STR"
%A_3 = alloca %"STR"
%AO = load %"STR_4" %A, align 16
%AO_0 = complex_extract ( %AO, 0 )
%AO_1 = complex_extract ( %AO, 1 )
%AO_2 = complex_extract ( %AO, 2 )
%AO_3 = complex_extract ( %AO, 3 )
store %"STR" AO_0, %"STR"* %A_0, align 4
store %"STR" AO_1, %"STR"* %A_1, align 4
store %"STR" AO_2, %"STR"* %A_2, align 4
store %"STR" AO_3, %"STR"* %A_3, align 4
call void @UnknownFun(%"STR"* %A_0)
call void @UnknownFun(%"STR"* %A_1)
call void @UnknownFun(%"STR"* %A_2)
call void @UnknownFun(%"STR"* %A_3)
%AON = complex_merge ( %A_0, %A_1, %A_2, %A_3 )
store %"STR_4" %AON, %"STR"* %A
ret void
}
```