This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: A patch for gcc.c-torture/execute/980505-1.c
- To: law at cygnus dot com
- Subject: Re: A patch for gcc.c-torture/execute/980505-1.c
- From: hjl at lucon dot org (H.J. Lu)
- Date: Fri, 12 Jun 1998 08:04:34 -0700 (PDT)
- Cc: egcs-patches at cygnus dot com
> > Hi,
> >
> > This patch seems to fix gcc.c-torture/execute/980505-1.c. But I
> > * cse.c (delete_trivially_dead_insns): Update REG_NOTES when
> > delete a insn.
> First, it would have helped if you included some information about
> exactly what problem you were trying to solve. You already have this
> information since you're working on the bug. I don't, so I had to
> go wandering through the archives to get my original analysis of
> this bug.
Here is the jump dump. As you can see,
static int f(int) __attribute__((const));
generates
(insn 17 15 19 (set (reg:SI 24)
(reg:SI 0 %eax)) -1 (nil)
(insn_list:REG_RETVAL 11 (expr_list:REG_EQUAL (expr_list (symbol_ref:SI ("f"))
(expr_list (reg/v:SI 23)
(nil)))
(nil))))
and
(insn 30 28 32 (set (reg:SI 25)
(reg:SI 0 %eax)) -1 (nil)
(insn_list:REG_RETVAL 24 (expr_list:REG_EQUAL (expr_list (symbol_ref:SI ("f"))
(expr_list (reg/v:SI 23)
(nil)))
(nil))))
In delete_trivially_dead_insns, SI 23 is deleted and is replaced by
const_int 1 and const_int 2, respectively. But it doesn't update
those NOTES. As the result, the compiler thinks both are the same.
With my patch, it generates
(insn 17 15 24 (set (reg:SI 24)
(reg:SI 0 %eax)) 59 {movsi+2} (nil)
(insn_list:REG_RETVAL 11 (expr_list:REG_EQUAL (expr_list (symbol_ref:SI ("f"))
(expr_list (const_int 1)
(nil)))
(nil))))
and
(insn 30 28 34 (set (reg:SI 25)
(reg:SI 0 %eax)) 59 {movsi+2} (nil)
(insn_list:REG_RETVAL 24 (expr_list:REG_EQUAL (expr_list (symbol_ref:SI ("f"))
(expr_list (const_int 2)
(nil)))
(nil))))
It seems to work. BTW, I sent in a new patch.
H.J.
-----
;; Function main
(note 2 0 3 "" NOTE_INSN_DELETED)
(note 3 2 4 "" NOTE_INSN_FUNCTION_BEG)
(note 4 3 6 "" NOTE_INSN_DELETED)
(note 6 4 9 0 NOTE_INSN_BLOCK_BEG)
(insn 9 6 11 (set (reg/v:SI 23)
(const_int 1)) -1 (nil)
(nil))
(insn 11 9 13 (set (mem:SI (pre_dec:SI (reg:SI 7 %esp)))
(reg/v:SI 23)) -1 (nil)
(insn_list:REG_LIBCALL 17 (nil)))
(call_insn/u 13 11 15 (set (reg:SI 0 %eax)
(call (mem:QI (symbol_ref:SI ("f")))
(const_int 4))) -1 (nil)
(nil)
(nil))
(insn 15 13 17 (set (reg:SI 7 %esp)
(plus:SI (reg:SI 7 %esp)
(const_int 4))) -1 (nil)
(nil))
(insn 17 15 19 (set (reg:SI 24)
(reg:SI 0 %eax)) -1 (nil)
(insn_list:REG_RETVAL 11 (expr_list:REG_EQUAL (expr_list (symbol_ref:SI ("f"))
(expr_list (reg/v:SI 23)
(nil)))
(nil))))
(insn 19 17 22 (set (reg/v:SI 21)
(reg:SI 24)) -1 (nil)
(nil))
(insn 22 19 24 (set (reg/v:SI 23)
(const_int 2)) -1 (nil)
(nil))
(insn 24 22 26 (set (mem:SI (pre_dec:SI (reg:SI 7 %esp)))
(reg/v:SI 23)) -1 (nil)
(insn_list:REG_LIBCALL 30 (nil)))
(call_insn/u 26 24 28 (set (reg:SI 0 %eax)
(call (mem:QI (symbol_ref:SI ("f")))
(const_int 4))) -1 (nil)
(nil)
(nil))
(insn 28 26 30 (set (reg:SI 7 %esp)
(plus:SI (reg:SI 7 %esp)
(const_int 4))) -1 (nil)
(nil))
(insn 30 28 32 (set (reg:SI 25)
(reg:SI 0 %eax)) -1 (nil)
(insn_list:REG_RETVAL 24 (expr_list:REG_EQUAL (expr_list (symbol_ref:SI ("f"))
(expr_list (reg/v:SI 23)
(nil)))
(nil))))