While looking through LAPACK I notices a few patterns. For example, in drotg,
"r = dsign(1.0d0,x)*y".  This is really "r = y ^ (x & sign-bit)".  Compare this
with "r = (1.0 | (x & sign-bit)) * y" when expanding copysign on most systems.

Note that this can get kinda complex.  See slasv2.f,

      IF( PMAX.EQ.1 )
     $   TSIGN = SIGN( ONE, CSR )*SIGN( ONE, CSL )*SIGN( ONE, F )
      IF( PMAX.EQ.2 )
     $   TSIGN = SIGN( ONE, SNR )*SIGN( ONE, CSL )*SIGN( ONE, G )
      IF( PMAX.EQ.3 )
     $   TSIGN = SIGN( ONE, SNR )*SIGN( ONE, SNL )*SIGN( ONE, H )
      SSMAX = SIGN( SSMAX, TSIGN )
      SSMIN = SIGN( SSMIN, TSIGN*SIGN( ONE, F )*SIGN( ONE, H ) )

Note that this is, depending on how you count, either 3 or 11 sequential
copysign-of-one-and-mult operations.

-- 
           Summary: Recognize common Fortran usages of copysign.
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rth at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19706

Reply via email to