On Thu, 6 Feb 2014, Richard Biener wrote:
>
> This re-writes posix_memalign calls to
>
> posix_memalign (ptr, align, size);
> tem = *ptr;
> tem = __builtin_assume_aligned (align);
> *ptr = tem;
>
> during CF lowering (yeah, ok ...) to make alignment info accessible
> to SSA based analysis.
>
> I have to adjust the added alias-31.c testcase again because with
> the above we end up with
>
> <bb 2>:
> res_3 = *p_2(D);
> posix_memalign (&q.q1, 128, 512);
> _5 = MEM[(void *)&q];
> _6 = __builtin_assume_aligned (_5, 128);
> MEM[(void *)&q] = _6;
> posix_memalign (&q.q2, 128, 512);
> _17 = res_3 + res_3;
> _20 = _17 + 1;
> _23 = _20 + 2;
> q ={v} {CLOBBER};
> return _23;
>
> after early DCE. This is because DCE only has "baby" DSE built-in
> and the store to MEM[(void *)&q] which it doesn't remove keeps
> the rest live. DSE removes the store and the DCE following it
> the rest.
>
> Not sure if more sophisticated lowering is wanted here. Special-casing
> &... operands to posix_memalign as stated in the PR, generating
> for posix_memalign (&ptr, 128, 512);
>
> posix_memalign (&tem, 128, 512);
> reg = tem;
> reg = __builtin_assume_aligned (reg, 128);
> ptr = reg;
>
> instead would be possible (hoping for ptr to become non-address-taken).
Ok, doing that was simple and avoids pessimizing the testcase.
Richard.