[cfe-commits] [PATCH] Invariants (and Assume Aligned) - Clang

Hal Finkel hfinkel at anl.gov
Wed Dec 5 14:45:27 PST 2012


----- Original Message -----
> From: "Tobias Grosser" <tobias at grosser.es>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: cfe-commits at cs.uiuc.edu, reviews+D149+public+707ba5224a940551 at llvm-reviews.chandlerc.com
> Sent: Wednesday, December 5, 2012 4:37:01 PM
> Subject: Re: [cfe-commits] [PATCH] Invariants (and Assume Aligned) - Clang
> 
> On 12/05/2012 11:29 PM, Hal Finkel wrote:
> > ----- Original Message -----
> >> From: "Tobias Grosser"<tobias at grosser.es>
> >> To:
> >> reviews+D149+public+707ba5224a940551 at llvm-reviews.chandlerc.com
> >> Cc: hfinkel at anl.gov, cfe-commits at cs.uiuc.edu
> >> Sent: Wednesday, December 5, 2012 4:04:54 PM
> >> Subject: Re: [cfe-commits] [PATCH] Invariants (and Assume Aligned)
> >> - Clang
> >>
> >> On 12/05/2012 09:39 PM, hfinkel at anl.gov wrote:
> >>>     Test cases have been enhanced. We now use @llvm.invariant.
> >>
> >>> Index: test/CodeGen/builtin-assume.c
> >>> ===================================================================
> >>> --- /dev/null
> >>> +++ test/CodeGen/builtin-assume.c
> >>> @@ -0,0 +1,9 @@
> >>> +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o
> >>> -
> >>> %s | FileCheck %s
> >>> +
> >>> +// CHECK: @test1
> >>> +int test1(int *a) {
> >>> +// CHECK: call void @llvm.invariant(i1
> >>> +  __builtin_assume(a != 0);
> >>> +  return a[0];
> >>
> >> The second check line looks incomplete? Is this intended?
> >
> > Yes. I did not want to match the variable name specifying the
> > condition.
> >
> > [For some reason, I can't see this comment in the web interface].
> 
> I have no account for the web interface, but hoped the emails would
> show
> up there anyway. Is this not the case?

It seems not.

> 
> Would you mind adding the entire test case (with some regexp magic)
> or
> in case this is too much work can you add an example to the
> documentation?

Sure. I'll try harder ;)

> Does __builtin_assume() basically take an i1 as an
> argument and allows an arbitrary set of instructions that lead to
> this
> i1. Can I have something, like
> 
> __builtin_assume(clamp(0, x, 100) >= 0);
> __builtin_assume(clamp(0, x, 100) <= 100);
> 
> to pass information about the behavior of the function clamp?

Yes; that's the idea. Currently, the only infrastructure I have is to apply this information to pointer alignments. In the future, the idea is to integrate this with ScalarEvolution, etc.

Thanks again,
Hal

> 
> I think this is a very nice feature, which will be very useful to
> polly.
> 
> Cheers
> Tobi
> 

-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory



More information about the cfe-commits mailing list