[PATCH] Added llvm.is.constant intrinsic

Joerg Sonnenberger joerg at britannica.bec.de
Mon Jun 30 07:01:24 PDT 2014


On Mon, Jun 30, 2014 at 03:04:21PM +0200, Sobczak, Janusz wrote:
> On 30 June 2014 13:13, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
> 
> > On Mon, Jun 30, 2014 at 10:45:24AM +0200, Sobczak, Janusz wrote:
> > > I'm thinking about modyfing __builtin_constant_p() implementation in
> > clang
> > > to do this (for integer arguments):
> > > if (argument is known to be constant)
> > >     replace  __builtin_constant_p() with 1 (True)
> > > else
> > >    replace __builtin_constant_p() with @llvm.is_constant() IR
> >
> > What is the intended use case here? All cases that *I* consider to be
> > sane applications of __builtin_constant_p are workaround for target
> > specific features that are better exposed as intrinsics themselve, e.g.
> > IO asm instructions on x86. It is one of the most abused features of
> > GCC, especially since it can introduce magic variance due to optimizer
> > changes.
> >
> 
> Please read the discussion here: http://llvm.org/bugs/show_bug.cgi?id=4898

I consider the original example from the Linux kernel bogus and I read
the discussion as agreeing with that. I haven't yet seen an example of
the performance improvements you mentioned. The whole conditions in the
original example will be folded away. If they are not, that's a bug.

Joerg



More information about the llvm-commits mailing list