Converting float -> double, double -> float

2024-04-30 Thread Lukasz Stafiniak
Hi!

I know these conversions are prohibited, because I get errors like:

  libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for
binary op: a: (float)(float *)0x55f43a23ac00[...] (type: float) b:
(float)n4[...] + (float)((float *)&n28)[...] (type: double)

The error does not trigger at the gcc_jit_context_new_cast conversion point
(n4 is double), the result of the conversion behaves as if it's still
double.
Auto-generated indices omitted.
I read through the discussions throughout the mailing list's history:
"Clarifying the permitted type conversions"
"Improve doc and comments regarding type casts"
"Handle truncation and extension for casts"
But I didn't find hints of a solution.
How can I make the conversions? Are there builtin functions to invoke?
I use libgccjit via bindings to OCaml.
The bindings haven't been updated in a long time, but I maintain them
and will be happy to update if there's anything missing.

Regards,
Lukasz


Building libgccjit with -fno-semantic-interposition? ( was Re: 1.76% performance loss in VRP due to inlining)

2024-04-30 Thread David Malcolm
On Tue, 2024-04-30 at 21:15 +0200, Richard Biener via Gcc wrote:
> 
> 
> > Am 30.04.2024 um 21:11 schrieb Jason Merrill via Gcc
> > :
> > 
> > On Fri, Apr 26, 2024 at 5:44 AM Aldy Hernandez via Gcc
> >  wrote:
> > > 
> > > In implementing prange (pointer ranges), I have found a 1.74%
> > > slowdown
> > > in VRP, even without any code path actually using the code.  I
> > > have
> > > tracked this down to irange::get_bitmask() being compiled
> > > differently
> > > with and without the bare bones patch.  With the patch,
> > > irange::get_bitmask() has a lot of code inlined into it,
> > > particularly
> > > get_bitmask_from_range() and consequently the wide_int_storage
> > > code.
> > ...
> > > +static irange_bitmask
> > > +get_bitmask_from_range (tree type,
> > > + const wide_int &min, const wide_int &max)
> > ...
> > > -irange_bitmask
> > > -irange::get_bitmask_from_range () const
> > 
> > My guess is that this is the relevant change: the old function has
> > external linkage, and is therefore interposable, which inhibits
> > inlining.  The new function has internal linkage, which allows
> > inlining.
> > 
> > Relatedly, I wonder if we want to build GCC with -fno-semantic-
> > interposition?
> 
> I guess that’s a good idea, though it’s already implied when doing
> LTO bootstrap and building cc1 and friends?  (But not for libgccjit?)

[CCing jit mailing list]

FWIW I've no idea if any libgccjit users are using semantic
interposition; I suspect the answer is "no one is using it".

Antoyo, Andrea [also CCed]: are either of you using semantic
interposition of symbols within libgccjit?

If not, we *might* get a slightly faster libgccjit by building it with
-fno-semantic-interposition.  Or maybe not...


Dave
 
> 
> Richard 
> 
> > 
> > Jason
> > 
>