public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: target/7374: __builtin_fabsl broken on alpha
@ 2002-09-07 23:03 sayle
  0 siblings, 0 replies; 2+ messages in thread
From: sayle @ 2002-09-07 23:03 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, snyder

Synopsis: __builtin_fabsl broken on alpha

State-Changed-From-To: open->closed
State-Changed-By: sayle
State-Changed-When: Sat Sep  7 23:03:37 2002
State-Changed-Why:
    This should now be fixed, both on mainline and on the
    3.2 branch (3.2.1 pre-release), by the following patch:
    
    2002-09-07  Scott Snyder  <snyder@fnal.gov>
    
            PR target/7374
            * config/alpha/alpha.md (abstf2): Fix typo: 'neg' for 'abs'.
    
    This is the patch originally proposed in the GNATS PR.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7374


^ permalink raw reply	[flat|nested] 2+ messages in thread

* target/7374: __builtin_fabsl broken on alpha
@ 2002-07-22  9:26 snyder
  0 siblings, 0 replies; 2+ messages in thread
From: snyder @ 2002-07-22  9:26 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-09-08  6:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-07 23:03 target/7374: __builtin_fabsl broken on alpha sayle
  -- strict thread matches above, loose matches on Subject: below --
2002-07-22  9:26 snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).