emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Emacs-diffs] trunk r114593: * lisp.h (eassert): Don't use 'assume'.


From: Stefan Monnier
Subject: Re: [Emacs-diffs] trunk r114593: * lisp.h (eassert): Don't use 'assume'.
Date: Fri, 11 Oct 2013 08:42:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> I've seen a lot of handwaving, but if there's a case where assume
> helps the compiler produce better code in Emacs, I've yet to see it
> presented.

Indeed, the cases where the compiler can optimize the code based on the
assume statement are fairly rare, because in most cases the programmer
has already done most of this work by hand.

I tend to agree with Daniel that `assert' should pretty much always be
"assert + assume", in theory.  In practice the fact that "assume" may
occasionally have a cost, and the fact that it rarely offers further
optimization opportunities, makes it less attractive than it appears
at first.

At the same time, this is all a tempest in a teapot: the difference
is minuscule either way.


        Stefan


PS: Cases where assert+assume could make a difference is if we only had
(say) the CAR macro but not the XCAR macro, in which case an
"assert+assume (CONSP (x))" could be used to tell the compiler that the
type test embedded in CAR can be skipped.
But of course, we don't trust the compiler to do this optimization for
us, so instead we created the XCAR macro, at which point the
"assert+assume (CONSP (x))" is no better than just "assert (CONSP (x))".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]