https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71977

            Bug ID: 71977
           Summary: powerpc64: Use VSR when operating on float and integer
           Product: gcc
           Version: 6.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tuliom at linux dot vnet.ibm.com
  Target Milestone: ---

The following code is common on libm:

#include <stdint.h>

typedef union
{
  float value;
  uint32_t word;
} ieee_float_shape_type;

float
mask_float (float f, uint32_t mask)
{ 
  ieee_float_shape_type u;

  u.value = f;
  u.word &= mask;

  return u.value;
}

GCC 6.1.1 is executing the operation in the GPR:

mask_float:
        xscvdpspn 12,1
        mfvsrd 9,12
        srdi 9,9,32
        and 4,4,9
        sldi 9,4,32
        mtvsrd 1,9
        xscvspdpn 1,1
        blr

However, operating in the VSR reduces the amount of instructions and improves
GPR pressure, e.g.:

mask_float2:
        sldi 4,4,32
        mtvsrd 0,4
        xvcvdpsp 1, 1
        xxland 1, 1, 0
        xvcvspdp 1, 1
        blr

Reply via email to