This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][AArch64] vrnd<*>_f64 patch for stage-1


On 02/13/2014 03:17 AM, Alex Velenko wrote:
> +/* Sets "rmode" field of "FPCR" control register to
> +   "FPROUNDING_ZERO".  */

Comment is wrong, or at least misleading.

> +void __inline __attribute__ ((__always_inline__))
> +set_rounding_mode (uint32_t mode)
> +{
> +  uint32_t r;
> +
> +  /* Read current FPCR.  */
> +  asm volatile ("mrs %[r], fpcr" : [r] "=r" (r) : :);
> +
> +  /* Clear rmode.  */
> +  r &= 3 << RMODE_START;

  ~(3 << RMODE_START)

> +  /* Calculate desired FPCR.  */
> +  r |= mode << RMODE_START;
> +
> +  /* Write desired FPCR back.  */
> +  asm volatile ("msr fpcr, %[r]" : : [r] "r" (r) :);
> +}

Fortunately for this testcase, you do always use FPROUNDING_ZERO == 3 when
calling this function, so the bugs are hidden.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]