target/7374: __builtin_fabsl broken on alpha

snyder@fnal.gov snyder@fnal.gov
Mon Jul 22 09:26:00 GMT 2002


>Number:         7374
>Category:       target
>Synopsis:       __builtin_fabsl broken on alpha
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 22 09:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.2 20020718 (experimental)
>Organization:
>Environment:
System: OSF1 d0ola.fnal.gov V5.1 732 alpha
Machine: alpha
	
host: alpha-dec-osf5.1
build: alpha-dec-osf5.1
target: alpha-dec-osf5.1
configured with: ../gcc/configure --prefix=/usr/local/egcs --enable-threads=posix --enable-long-long : (reconfigured) ../gcc/configure --prefix=/scratch/snyder/gcc/inst --enable-threads=posix --enable-long-long : (reconfigured) ../gcc/configure --prefix=/scratch/snyder/gcc/inst --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77
>Description:


On the alpha, the program below is miscompiled --- it prints -1
instead of 1:

$ gcc -o x x.c 
$ ./x
-1.000000
$


Here's the generated code for foo().
It looks to me like this code is negating the argument, rather
than taking the absolute value.


        .ent foo
$foo..ng:
foo:
        .frame $15,16,$26,0
        .mask 0x4008000,-16
        lda $30,-16($30)
        stq $26,0($30)
        stq $15,8($30)
        bis $31,$30,$15
        .prologue 0
        bis $31,$16,$0
        bis $31,$17,$1
        ldq $2,0($1)
        ldq $3,8($1)
        lda $1,-1($31)
        sll $1,63,$1
        xor $1,$3,$3
        bis $31,$2,$1
        bis $31,$3,$2
        stq $1,0($0)
        stq $2,8($0)
        bis $31,$15,$30
        ldq $26,0($30)
        ldq $15,8($30)
        lda $30,16($30)
        ret $31,($26),1
        .end foo


Indeed, in alpha.md, i find this:

(define_expand "abstf2"
  [(parallel [(set (match_operand:TF 0 "register_operand" "")
		   (neg:TF (match_operand:TF 1 "reg_or_0_operand" "")))
	      (use (match_dup 2))])]
  "TARGET_HAS_XFLOATING_LIBS"
{
#if HOST_BITS_PER_WIDE_INT >= 64
  operands[2] = force_reg (DImode, GEN_INT ((HOST_WIDE_INT) 1 << 63));
#else
  operands[2] = force_reg (DImode, immed_double_const (0, 0x80000000, DImode));
#endif
})


Note the `neg' here.  If i change this to `abs' (patch below),
then i get the correct results from this test program.



>How-To-Repeat:


------------------------------------------------------------------------
long double foo (long double xx)
{
  return __builtin_fabsl (xx);
}


int main() {
  long double xx = 1.0;
  long double yy = foo (xx);
  printf ("%f\n", (float) (yy));
  return 0;
}

------------------------------------------------------------------------

>Fix:


2002-07-22  scott snyder  <snyder@fnal.gov>

	* config/alpha/alpha.md (abstf2): Fix typo: `neg' for `abs'.

Index: config/alpha/alpha.md
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/config/alpha/alpha.md,v
retrieving revision 1.194
diff -u -c -r1.194 alpha.md
*** config/alpha/alpha.md	14 Jun 2002 20:26:23 -0000	1.194
--- config/alpha/alpha.md	22 Jul 2002 16:15:23 -0000
***************
*** 2134,2140 ****
  
  (define_expand "abstf2"
    [(parallel [(set (match_operand:TF 0 "register_operand" "")
! 		   (neg:TF (match_operand:TF 1 "reg_or_0_operand" "")))
  	      (use (match_dup 2))])]
    "TARGET_HAS_XFLOATING_LIBS"
  {
--- 2134,2140 ----
  
  (define_expand "abstf2"
    [(parallel [(set (match_operand:TF 0 "register_operand" "")
! 		   (abs:TF (match_operand:TF 1 "reg_or_0_operand" "")))
  	      (use (match_dup 2))])]
    "TARGET_HAS_XFLOATING_LIBS"
  {

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list