This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [arm] VFP unsigned float conversion
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Paul Brook <paul at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 15 Apr 2004 12:36:13 +0100
- Subject: Re: [arm] VFP unsigned float conversion
- References: <200404081604.40140.paul@codesourcery.com>
On Thu, 2004-04-08 at 16:04, Paul Brook wrote:
> The following patch adds patterns for vfp unsigned int <-> float conversion.
>
> Tested with cross-sompiler to arm-none-elf
> Ok?
>
> Paul
>
> 2004-04-08 Paul Brook <paul@codesourcery.com>
>
> * config/arm/arm.md (fixuns_truncsfsi2, fixuns_truncdfsi2,
> floatunssisf2, floatunssidf2): New patterns.
>
> +(define_insn "fixuns_truncsfsi2"
> + [(set (match_operand:SI 0 "s_register_operand" "=w")
> + (unsigned_fix:SI (match_operand:SF 1 "s_register_operand" "w")))]
> + "TARGET_ARM && TARGET_HARD_FLOAT && TARGET_VFP"
> + "ftouizs%?\\t%0, %1"
> + [(set_attr "predicable" "yes")
> + (set_attr "type" "farith")]
> +)
rtl.texi says:
@findex fix
@item (fix:@var{m} @var{x})
When @var{m} is a fixed point mode, represents the result of
converting floating point value @var{x} to mode @var{m}, regarded as
signed. How rounding is done is not specified, so this operation may
be used validly in compiling C code only for integer-valued operands.
@findex unsigned_fix
@item (unsigned_fix:@var{m} @var{x})
Represents the result of converting floating point value @var{x} to
fixed point mode @var{m}, regarded as unsigned. How rounding is done
is not specified.
@findex fix
@item (fix:@var{m} @var{x})
When @var{m} is a floating point mode, represents the result of
converting floating point value @var{x} (valid for mode @var{m}) to an
integer, still represented in floating point mode @var{m}, by rounding
towards zero.
@end table
So technically, your patterns have unspecified rounding. To be formally
correct the pattern should be:
+(define_insn "fixuns_truncsfsi2"
+ [(set (match_operand:SI 0 "s_register_operand" "=w")
+ (unsigned_fix:SI (fix:SF (match_operand:SF 1 "s_register_operand" "w"))))]
+ "TARGET_ARM && TARGET_HARD_FLOAT && TARGET_VFP"
+ "ftouizs%?\\t%0, %1"
+ [(set_attr "predicable" "yes")
+ (set_attr "type" "farith")]
R.