GDC generates invalid assembly around fiber yield operations (Not re-reading data from clobberedd memory to registers)
Johannes Pfau via D.gnu
d.gnu at puremagic.com
Fri May 15 00:34:05 PDT 2015
Am Fri, 15 May 2015 09:23:33 +0200
schrieb "Iain Buclaw via D.gnu" <d.gnu at puremagic.com>:
> On 15 May 2015 at 09:13, Iain Buclaw <ibuclaw at gdcproject.org> wrote:
> > On 15 May 2015 at 09:08, Johannes Pfau via D.gnu
> > <d.gnu at puremagic.com> wrote:
> >> Am Thu, 14 May 2015 19:02:48 +0200
> >> schrieb Johannes Pfau <nospam at example.com>:
> >>
> >>> ...
> >>
> >> TLDR
> >> As a workaround replace
> >>
> >> globalSum += otherFunc();
> >>
> >> which GDC currently treats as
> >>
> >> globalSum = globalSum + otherFunc();
> >>
> >> with
> >>
> >> globalSum = otherFunc() + globalSum;
> >>
> >
> > That is an interesting workaround, should we perhaps reconsider our
> > code generation here?
> >
>
> I can confirm that C codegen does infact emit 'foo += bar()' as 'foo
> = bar() + foo'
>
> Which only strengthens the reasoning to change it.
>
> Liran, can you raise a bug report? Also, can we use your small sample
> (names will be anonymised) to put into the testsuite?
>
>
> Regards
> Iain.
BTW: For commutative operations we can simply change the operands. For
non-commutative operations we'll have to explicitly evaluate the side
effects of the RHS before assigning. (-=, ...)
Relevant code is in d-elem.cc: AddAssignExp::toElem etc
More information about the D.gnu
mailing list