[llvm-dev] [RFC] Adding range metadata to array subscripts.

Clement Courbet via llvm-dev llvm-dev at lists.llvm.org
Sun Mar 28 22:43:15 PDT 2021


On Sun, Mar 28, 2021 at 5:44 PM Johannes Doerfert via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

>
> On 3/28/21 3:49 AM, James Courtier-Dutton wrote:
> > Actual use cases can get much more complicated with for example,
> > non-contiguous ranges. e.g. 0,1,4,5 ok, but 2,3,6,7 not ok.
>

This can actually be represented by !range metadata, but only for constant
values.


> That said, in operand bundles we can generally allow non-constant
> values, e.g., `["range"(%p, i32 0, i32 %N)]`
>

That's a good point and it essentially disqualifies !range metadata if
we want to one day be able to deal with values..

> This means we have to handle multiple variants across the codebase, which
can lead to situations where only one or the other is handled

I don't think this is really an issue, because whatever the choice of
representation is, all these variants should be using `ValueTracking` to
abstract the representation anyway.

> I'm not sure I understand the questions properly. It basically is range
metadata attached to an arbitrary value for a fixed program point. Could
you elaborate on your comments wrt. the connection to option 2 and 3,
please.

It's just that I was not sure about the internal representation, but you've
answered by question: It's internally a different concept from !range
metadata, so I'll need to teach ValueTracking about it.


> ~ Johannes
>
>
> > Kind Regards
> >
> > James
> >
> >
> >
> >
> >>>>>> On 3/24/21 9:06 AM, Clement Courbet wrote:
> >>>>>>> On Wed, Mar 24, 2021 at 2:20 PM Johannes Doerfert <
> >>>>>>> johannesdoerfert at gmail.com> wrote:
> >>>>>>>
> >>>>>>>> I really like encoding more (range) information in the IR,
> >>>>>>>> more thoughts inlined.
> >>>>>>>>
> >>>>>>>> On 3/24/21 4:14 AM, Clement Courbet via llvm-dev wrote:
> >>>>>>>>> struct Histogram {
> >>>>>>>>>
> >>>>>>>>>      int values[256];
> >>>>>>>>>
> >>>>>>>>>      int total;
> >>>>>>>>>
> >>>>>>>>> };
> >>>>>>>>>
> >>>>>>>>> Histogram DoIt(const int* image, int size) {
> >>>>>>>>>
> >>>>>>>>>      Histogram histogram;
> >>>>>>>>>
> >>>>>>>>>      for (int i = 0; i < size; ++i) {
> >>>>>>>>>
> >>>>>>>>>        ++histogram.values[image[i]];  // (A)
> >>>>>>>>>
> >>>>>>>>>        ++histogram.total;             // (B)
> >>>>>>>>>
> >>>>>>>>>      }
> >>>>>>>>>
> >>>>>>>>>      return histogram;
> >>>>>>>>>
> >>>>>>>>> }
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210329/d4cee55b/attachment.html>


More information about the llvm-dev mailing list