public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* A bug in mark_constants () in varasm.c
@ 1998-03-13 18:47 H.J. Lu
  1998-03-16 20:44 ` Jim Wilson
  0 siblings, 1 reply; 19+ messages in thread
From: H.J. Lu @ 1998-03-13 18:47 UTC (permalink / raw)
  To: egcs

With egcs 980312 09:16am PST configured for linux/x86. I got the
undefined label ".LC1":

# cc -S -O2 -march=i686 -B/home/work/gnu/bin/egcs/gcc/ -dra r_tanh.c
# gcc -c r_tanh.s
# r_tanh.o
         U .LC1
00000000 t gcc2_compiled.
00000000 T tanh

The problem is mark_constants () in varasm.c. Here is the comment in
mark_constants ():

  /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
     a MEM, but does not constitute a use of that MEM.  This is particularly    
     important inside a nested function, because CONST_DOUBLE_MEM may be
     a reference to a MEM in the parent's constant pool.  See the comment       
     in force_const_mem.  */
      
  else if (GET_CODE (x) == CONST_DOUBLE)
    return;                         

As you can see in r_tanh.c.stack, .LC1 is used. But mark_constants ()
doesn't search inside CONST_DOUBLE. That causes the problem. Could
someone please fix it?

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---r_tanh.c---
extern __inline  double
__expm1 (double __x)
{
  double __temp;
  __temp = 1.0;
  return __temp;
}
extern __inline  double
__sgn1 (double __x)
{
  return __x >= 0.0 ? 1.0 : -1.0;
}
double
tanh (double __x)
{
  return  __expm1 (__x) * __sgn1 (-__x);
}
----r_tanh.c.stack----

;; Function tanh

(note 2 0 5 "" NOTE_INSN_DELETED)

(note 5 2 6 "" NOTE_INSN_FUNCTION_BEG)

(note 6 5 8 "" NOTE_INSN_DELETED)

(note 8 6 9 "" NOTE_INSN_BLOCK_BEG)

(note 9 8 10 "" NOTE_INSN_BLOCK_BEG)

(note/i 10 9 12 "" NOTE_INSN_BLOCK_BEG)

(note/i 12 10 15 "" NOTE_INSN_DELETED)

(note/i 15 12 17 "" NOTE_INSN_BLOCK_END)

(note 17 15 21 "" NOTE_INSN_BLOCK_END)

(note 21 17 48 "" NOTE_INSN_BLOCK_BEG)

(note 48 21 52 "" NOTE_INSN_DELETED)

(note 52 48 54 "" NOTE_INSN_DELETED)

(note 54 52 36 "" NOTE_INSN_DELETED)

(note 36 54 39 "" NOTE_INSN_BLOCK_END)

(note 39 36 44 "" NOTE_INSN_DELETED)

(note 44 39 55 "" NOTE_INSN_BLOCK_END)

(note 55 44 57 "" NOTE_INSN_DELETED)

;; Insn is not within a basic block
(insn 57 55 59 (set (mem:SI (pre_dec:SI (reg:SI 7 %esp)))
        (reg:SI 6 %ebp)) 49 {movsi-2} (nil)
    (nil))

;; Insn is not within a basic block
(insn 59 57 56 (set (reg:SI 6 %ebp)
        (reg:SI 7 %esp)) 53 {movsi+2} (insn_list 57 (nil))
    (nil))

;; Start of basic block 0, registers live: 6 [bp]
(note 56 59 4 "" NOTE_INSN_PROLOGUE_END)

(insn:QI 4 56 18 (set (reg:DF 8 %st(0))
        (mem:DF (plus:SI (reg:SI 6 %ebp)
                (const_int 8)))) 76 {movdf_mem+1} (insn_list 59 (insn_list 57 (nil)))
    (expr_list:REG_EQUIV (mem:DF (plus:SI (reg:SI 6 %ebp)
                (const_int 8)))
        (nil)))

(insn:QI 18 4 22 (set (reg:DF 8 %st(0))
        (neg:DF (reg:DF 8 %st(0)))) 197 {negdf2} (insn_list 4 (nil))
    (nil))

(insn/i:QI 22 18 65 (set (reg:DF 8 %st(0))
        (const_double:DF (cc0) 0 0 0)) 76 {movdf_mem+1} (nil)
    (expr_list:REG_EQUIV (const_double:DF (cc0) 0 0 0)
        (nil)))

(insn:QI 65 22 49 (parallel[ 
            (set (reg:DF 9 %st(1))
                (reg:DF 8 %st(0)))
            (set (reg:DF 8 %st(0))
                (reg:DF 9 %st(1)))
        ] ) -1 (nil)
    (nil))

(insn:QI 49 65 50 (parallel[ 
            (set (cc0)
                (compare (reg:DF 8 %st(0))
                    (reg:DF 9 %st(1))))
            (clobber (reg:HI 0 %ax))
        ] ) 25 {cmpsf_cc_1-7} (insn_list 18 (insn_list 22 (nil)))
    (expr_list:REG_DEAD (reg:DF 9 %st(1))
        (expr_list:REG_DEAD (reg:DF 8 %st(0))
            (expr_list:REG_UNUSED (reg:HI 0 %ax)
                (nil)))))

(insn/s:QI 50 49 64 (set (reg:DF 8 %st(0))
        (if_then_else:DF (ge (cc0)
                (const_int 0))
            (const_double:DF (cc0) 0 0 1073709056)
            (const_double:DF (mem/u:DF (symbol_ref/u:SI ("*.LC1"))) 0 0 -1073774592))) 380 {movdfcc_1} (insn_list 22 (insn_list 18 (nil)))
    (nil))

(note 64 50 61 "" NOTE_INSN_EPILOGUE_BEG)

(insn 61 64 62 (parallel[ 
            (set (reg:SI 7 %esp)
                (reg:SI 6 %ebp))
            (clobber (reg:SI 6 %ebp))
        ] ) 343 {epilogue_set_stack_ptr} (insn_list:REG_DEP_OUTPUT 57 (insn_list 59 (insn_list:REG_DEP_ANTI 4 (nil))))
    (nil))

(insn 62 61 40 (parallel[ 
            (set (reg:SI 6 %ebp)
                (mem:SI (reg:SI 7 %esp)))
            (set (reg:SI 7 %esp)
                (plus:SI (reg:SI 7 %esp)
                    (const_int 4)))
        ] ) 345 {pop} (insn_list 57 (insn_list 61 (nil)))
    (nil))

(insn:QI 40 62 63 (use (reg/i:DF 8 %st(0))) -1 (insn_list 50 (nil))
    (nil))

(jump_insn/s 63 40 60 (return) 334 {return_internal} (insn_list:REG_DEP_ANTI 62 (insn_list 50 (nil)))
    (nil))
;; End of basic block 0

(barrier 60 63 0)


^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: A bug in mark_constants () in varasm.c
@ 1998-03-19 12:55 Pal Engstad
  1998-03-21 10:36 ` H.J. Lu
  1998-03-21 10:36 ` Per Bothner
  0 siblings, 2 replies; 19+ messages in thread
From: Pal Engstad @ 1998-03-19 12:55 UTC (permalink / raw)
  To: egcs

Hi,

I really do appreciate all your efforts into making gcc such a lovely
compiler, but I do think you need to follow some better programing 
style guidelines.

Linus Torvalds requires that all code in the source is using a tab
length of 8 spaces, and he also states that you are a bad programmer
if you write code with more than 3 indentation levels.

This has caused the code to be fairly easy to read and maintainance is
pretty straight forward.

When I see patches like this I frown. 
	
	DISABLE THE COPY & PASTE FUNCTIONS IN YOUR EDITOR!

Instead of making duplicate code in two places, make a function out of
it. How hard is that?

static void 
erase_reg_from_regstack(int regno, regstack_t regstack, int top)
{
    if (regstack->reg [top] != regno)
      {
         int i;
         if (! have_cmove)
           abort ();
         for (i = regstack->top; i >= 0; i--)
           if (regstack->reg [i] == regno)
             {
               int j;
               for (j = i; j < top; j++)
                 regstack->reg [j] = regstack->reg [j + 1];
               break;
             }
      }
}

I don't know what type regstack is, so please bear with me.

PKE.

^ permalink raw reply	[flat|nested] 19+ messages in thread
* RE: A bug in mark_constants () in varasm.c
@ 1998-03-24 14:49 Kaz Kylheku
  1998-03-27 15:18 ` Andreas Schwab
  0 siblings, 1 reply; 19+ messages in thread
From: Kaz Kylheku @ 1998-03-24 14:49 UTC (permalink / raw)
  To: 'Joe Buck', Per Bothner; +Cc: engstad, egcs

On Monday, March 23, 1998 9:47 AM, Joe Buck [SMTP:jbuck@synopsys.com] wrote:
> Pal Engstad writes:
> > > Linus Torvalds requires that all code in the source is using a tab
> > > length of 8 spaces, and he also states that you are a bad programmer
> > > if you write code with more than 3 indentation levels.
> 
> Linus has also said that the GNU coding standards should be burned.
> Since gcc uses the GNU coding standards, it isn't going to make Linus
> happy.  The gcc developers aren't going to reject the GNU coding
> standards because Linus says so.

I agree that the GNU coding standards should be burned. It's plain
silly to indent code like this:

for (;;)
  {
    /* whatever */
    if (condition)
      {
         /* whatever */

Can you say ``adolescent rebellion against K&R?''

I don't believe that Linus would have said, at least not seriously, that
one who uses more than three levels of nesting is bad programmer.

There is something said about this in the brief document which describes
the Linux coding conventions. If I recall, it's to the effect that
deep nesting is rarely necessary. The whole document is rather
jestful in nature, anyway.


^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: A bug in mark_constants () in varasm.c
@ 1998-04-02  8:21 Christian Iseli
  0 siblings, 0 replies; 19+ messages in thread
From: Christian Iseli @ 1998-04-02  8:21 UTC (permalink / raw)
  To: egcs, Marc.Espie

> Well, apart from coding standards, there are some parts that would
> benefit from cleaner coding. It sometimes seem that the guys who
> develop gcc don't believe the compiler knows how to optimize stuff :-)
> 
> Just have a look at cccp.c, as I did to understand how gcc was looking up
> include paths, to see how difficult it was to add an helpful error message
> when #include <myheader> fails because I should have said 
> #include "myheader". 
> ... (snipped)

Hmm, well... now that you have spent time analyzing the thing and rubbing our noses
in the dunk, are you going to submit patches to fix those problems ?

					Christian

P.S. April fools' day... so the ;-)'s are implied...

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

end of thread, other threads:[~1998-04-02  9:35 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-13 18:47 A bug in mark_constants () in varasm.c H.J. Lu
1998-03-16 20:44 ` Jim Wilson
1998-03-17  8:42   ` H.J. Lu
1998-03-18 14:08     ` Jim Wilson
1998-03-18 14:08       ` H.J. Lu
1998-03-17 11:33   ` H.J. Lu
1998-03-19 12:55 Pal Engstad
1998-03-21 10:36 ` H.J. Lu
1998-03-21 10:36 ` Per Bothner
1998-03-23 15:35   ` Joe Buck
1998-03-23 22:59     ` Jeffrey A Law
1998-03-24  9:27       ` Craig Burley
1998-03-31  0:46       ` Marc Espie
1998-04-02  9:35         ` Jeffrey A Law
1998-03-24 12:23     ` Wolfram Gloger
1998-03-23 19:24   ` Pal Engstad
1998-03-24 14:49 Kaz Kylheku
1998-03-27 15:18 ` Andreas Schwab
1998-04-02  8:21 Christian Iseli

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).