ispc/ispc — Issue #147: Poor code with generic targets for simple function
Author: mmp
Created: 2012-01-05 00:21:03+00:00
State: open
Labels: bugs, performance

Given

```
float foo(float a, float b) {
float r;
r = a+b;
return r;
}
```

The generic-4 target generates this bad IR:

```
define <4 x float> @foo___ff(<4 x float> %a, <4 x float> %b, <4 x i1> %__mask) nounwind readnone {
allocas:
%return_value_memory = alloca <4 x float>
%binop = fadd <4 x float> %a, %b
%ptr_to_int32vecptr = bitcast <4 x float>* %return_value_memory to <4 x i32>*
%value_to_int32 = bitcast <4 x float> %binop to <4 x i32>
store <4 x i32> %value_to_int32, <4 x i32>* %ptr_to_int32vecptr, align 4
%return_value = load <4 x float>* %return_value_memory, align 1
ret <4 x float> %return_value
}
```

Whereas e.g. sse4 just generates a single fadd and a ret.