[PATCH] D155049: [ScalarEvolution] Infer loop max trip count from memory accesses

Florian Mayer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 17:11:01 PDT 2023


fmayer added a comment.

In D155049#4651545 <https://reviews.llvm.org/D155049#4651545>, @fmayer wrote:

> In D155049#4651544 <https://reviews.llvm.org/D155049#4651544>, @jdoerfert wrote:
>
>> In D155049#4651543 <https://reviews.llvm.org/D155049#4651543>, @fmayer wrote:
>>
>>> In D155049#4651542 <https://reviews.llvm.org/D155049#4651542>, @vitalybuka wrote:
>>>
>>>> How this is going to affect sanitizers? We still want them being able to detect overflows.
>>>
>>> more context: sanitizers use SCEV to decide to not instrument accesses where SCEV tells us that they are in range. With features like this that exploit UB in SCEV, we can no longer rely on this, because the whole point of the sanitizer is to catch UB.
>>
>> SCEV (and other helpers) already refine UB, don't they? That said, you can disable the feature, right now via a command line flag. That said, we probably want a "catch all" try not to exploit UB flag.
>
> Thanks! Yes such a catch all would be great. Just confirming I understand the CL correctly (I didn't actually read all of the code). If I take the loop from the discourse
>
>   int square(int num) {
>       int A[3];
>       for (int i = 0; i < num; ++i)
>         A[i] = i * num;
>       return A[1] + A[2];
>   }
>
> SCEV would tell me that `0 <= i < 3` is true?

And also `num < 3`?


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

https://reviews.llvm.org/D155049



More information about the llvm-commits mailing list