[PATCH] D100785: [InstCombine] Enhance deduction of alignment for aligned_alloc

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 19 17:02:35 PDT 2021


xbolva00 added a comment.

In D100785#2700023 <https://reviews.llvm.org/D100785#2700023>, @jdoerfert wrote:

> In D100785#2699469 <https://reviews.llvm.org/D100785#2699469>, @xbolva00 wrote:
>
>> In D100785#2699460 <https://reviews.llvm.org/D100785#2699460>, @jdoerfert wrote:
>>
>>>> The function aligned_alloc() is the same as memalign(), except for the added restriction that size should be a multiple of alignment. So for a non-zero alignment size need to be non-zero.
>>>
>>> I don't think the last part is true, 0 x Alignment = 0. That said, for non-zero sizes we know alignment holds, so this is fine.
>>
>> So should we just drop isKnownNonZero check? To allow annotation for case like aligned_alloc(32, dynamicsize)?
>
> No, isKnownNonZero is the important part.
>
>   p = aligned_alloc(32, dynamicsize)
>   ===>
>   dynamicsize == 0 || p % 32 == 0
>
> (if p would be null for size = 0 we could avoid the check but the standard allows for a special pointer return I think)

Ah, right. Reverted to previous version which was OK. Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100785/new/

https://reviews.llvm.org/D100785



More information about the llvm-commits mailing list