[llvm-commits] LLVM patch to support ARM fused multiply add/subtract instructions

Hal Finkel hfinkel at anl.gov
Tue Jan 24 07:12:48 PST 2012


On Tue, 2012-01-24 at 13:44 +0300, Anton Korobeynikov wrote:
> Cameron,
> 
> > There needs to be a new flag for the automatic use of excess precision, if that behavior is even desired.
> Right. Maybe -ffast-math should imply this flag as well.

I think that we already have a way for dealing with this (which is what
PPC uses for its FMA patterns); see Target/TargetOptions.h which
includes the following:

/// LessPreciseFPMAD - This flag is enabled when the
/// -enable-fp-mad is specified on the command line.  When this flag is
off
/// (the default), the code generator is not allowed to generate mad
/// (multiply add) if the result is "less precise" than doing those
/// operations individually.
unsigned LessPreciseFPMADOption : 1;
...

/// NoExcessFPPrecision - This flag is enabled when the
/// -disable-excess-fp-precision flag is specified on the command line.
/// When this flag is off (the default), the code generator is allowed
to
/// produce results that are "more precise" than IEEE allows.  This
includes
/// use of FMA-like operations and use of the X86 FP registers without
/// rounding all over the place.
unsigned NoExcessFPPrecision : 1;

/// UnsafeFPMath - This flag is enabled when the
/// -enable-unsafe-fp-math flag is specified on the command line.  When
/// this flag is off (the default), the code generator is not allowed to
/// produce results that are "less precise" than IEEE allows.  This
includes
/// use of X86 instructions like FSIN and FCOS instead of libcalls.
/// UnsafeFPMath implies LessPreciseFPMAD.
unsigned UnsafeFPMath : 1;

So depending on whether your FMA instructions are more or less precise
than the original instruction combination, you can predicate them on one
of these flags as necessary. For example, the PPC backend defines:
def FPContractions : Predicate<"!TM.Options.NoExcessFPPrecision">;
and then uses this to restrict the application of the patterns for
fpmadd and similar instructions.

 -Hal

> 

-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory




More information about the llvm-commits mailing list