[PATCH 4/5] ARM: Cleanup fenv implementation
Joseph S. Myers
joseph@codesourcery.com
Wed Jun 11 17:13:00 GMT 2014
On Wed, 11 Jun 2014, Wilco wrote:
> Joseph wrote:
> > On Tue, 10 Jun 2014, Wilco wrote:
> >
> > > This is a series of patches which improves the ARM fenv implementation.
> > > Improve rounding mode check in libc_fesetround_vfp and
> > > libc_feholdsetround_vfp so it ignores out of range values.
> >
> > I don't see this as an improvement. Invalid rounding modes should never
> > get here, and it's confusing to change a variable called "round" to
> > something other than the rounding mode.
>
> It's not only safer (for the unlikely case where you pass an incorrect
> rounding mode) but also faster as it saves an instruction and enables the use
> of CBZ. Note the AAarch64 version is exactly the same.
But this is an internal function that should never be able to receive an
invalid rounding mode (if necessary, the caller, e.g. fesetround, should
check), and the compiler should be able to see at each call site that only
valid rounding modes can get there. If the two don't generate the same
code for some caller, then that suggests a microoptimization issue to be
addressed in GCC.
> Maybe naming it "round_adjust" or "round_diff" would make it clearer?
Ordinary C usage would be "if (A != B)" not "if ((A ^ B) != 0)". It's the
compiler's job to convert the former into the latter if that's the best
code sequence on a particular processor; the former is more idiomatic for
humans, and gives the compiler just as much information, so is to be
preferred.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list