[M3devel] eliminating volatile on floats

Jay K jay.krell at cornell.edu
Sun Jul 4 17:01:53 CEST 2010


The #if 0 didn't seem to work.
I'll go with ter = 0 for now.
Then maybe look at what equivalent C does.
I still think the problem is maybe something about alignment, more than type punning/aliases, though they are related.
I checked some obvious things, like, if alignment of int/long/float/double/void* were other than I expected in C.


I'll go with ter = 0 for now.
I think I'll commit that as some steps forward and backward but not a bad tradeoff.
Granted, I don't know really what ter is and how effective it is, but O1, O2, O3 are each a "bundle"
of quite a number of optimizations. Throwing out some of them seems not too terrible.
Throwing in volatile definitely defeats a lot, and probably not the ones I turn off.



 - Jay

----------------------------------------
> From: hosking at cs.purdue.edu
> Date: Sun, 4 Jul 2010 10:49:55 -0400
> To: jay.krell at cornell.edu
> CC: m3devel at elegosoft.com
> Subject: Re: [M3devel] eliminating volatile on floats
>
> I don't understand what we would need to do to fix this without the hack of commenting out gcc functionality. Better to give gcc something it likes than to hack it.
>
> On 4 Jul 2010, at 10:25, Jay K wrote:
>
> >
> > Through simple trial/error I've tracked a need (the only need?) for floats down:
> >
> > If I set flag_tree_ter = 0, I can compile m3core where I couldn't before, with -O3.
> >
> >
> > I suspect due to:
> >
> > builtins.c:
> >
> > int
> > get_pointer_alignment (tree exp, unsigned int max_align)
> > {
> > unsigned int align, inner;
> >
> > /* We rely on TER to compute accurate alignment information. */
> > if (!(optimize && flag_tree_ter))
> > return 0;
> >
> >
> > Another thing to try is #if 0 out this block of code (it is not in parse,c but "gcc itself").
> > That should yield more optimization, but more patch to gcc.
> > I'm inclined to try that.
> >
> >
> > There should be additional options, like getting the alignment correct or such.
> >
> >
> > The code that fails to compile is:
> > /dev2/cm3/m3-libs/m3core/src/float/IEEE/LongFloat.m3
> >
> >
> > PROCEDURE CopySign (x, y: T): T =
> > VAR res := x;
> > BEGIN
> > LOOPHOLE (res, Rep.T).sign := LOOPHOLE (y, Rep.T).sign;
> > RETURN res;
> > END CopySign;
> >
> >
> > I also tried some other options like adding volatile and/or temporaries on loophole's using t_struct.
> >
> >
> > (To be clear, we only have volatile on float loads, not stores, though I think only stores would be preferable to only loads.
> > "reads are more common than writes", "consider the registers to be a write-through cache")
> >
> >
> > - Jay
> >
>
 		 	   		  


More information about the M3devel mailing list