[LLVMdev] Loads not hoisted out of the loop

Krzysztof Parzyszek kparzysz at codeaurora.org
Fri Jan 18 06:36:30 PST 2013

On 1/17/2013 11:33 PM, Owen Anderson wrote:
> Almost certainly, the compiler can't tell that the load from the struct
> (to get the array pointer) doesn't alias with the stores to the array
> itself.  This is exactly the kind of thing that type-based alias
> analysis (-fstrict-aliasing) can help with.   Use with caution, as it
> can break some type-unsafe idioms.

The problem is actually the stores to out->data.  While "d" and "out" 
are restricted pointers, it tells us nothing about the relation between 
"d->data" and "out->data", since the "data" member is a pointer itself. 
  Since both "d->data" and "out->data" are both of type double, the 
type-based alias analysis won't help.

In the case when you pass "double*" to the function, the restrict 
keyword tells us that the arrays of doubles themselves do not alias, 
which allows the compiler to infer that the loads and stores in the loop 
do not depend on each other.


Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

More information about the llvm-dev mailing list