From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12312 invoked by alias); 22 Jul 2002 16:26:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 12291 invoked by uid 71); 22 Jul 2002 16:26:01 -0000 Resent-Date: 22 Jul 2002 16:26:01 -0000 Resent-Message-ID: <20020722162601.12290.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, snyder@fnal.gov Received: (qmail 7645 invoked from network); 22 Jul 2002 16:19:07 -0000 Received: from unknown (HELO karma.fnal.gov) (131.225.227.85) by sources.redhat.com with SMTP; 22 Jul 2002 16:19:07 -0000 Received: (from sss@localhost) by karma.fnal.gov (8.11.6/8.11.6) id g6MGHSf11484; Mon, 22 Jul 2002 11:17:28 -0500 Message-Id: <200207221617.g6MGHSf11484@karma.fnal.gov> Date: Mon, 22 Jul 2002 09:26:00 -0000 From: snyder@fnal.gov Reply-To: snyder@fnal.gov To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: 3.113 Subject: target/7374: __builtin_fabsl broken on alpha X-SW-Source: 2002-07/txt/msg00603.txt.bz2 List-Id: >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 * 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: