This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix incorrect ifcvt data flow computation
- From: Joern Rennecke <joern dot rennecke at superh dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 20 Apr 2004 16:28:25 +0100 (BST)
- Subject: fix incorrect ifcvt data flow computation
ifcvt.c:dead_or_predicable uses local_set as computed by propagate_block
to determine which registers are changed in a piece of code. However,
propagate_one_insn doesn't include updates of a stack pointer where a
CONST_INT is added to the stack pointer. This resulted in the wrong
value of the stack pointer when branching to label 432 in the exapmle
below after if-conversion (r15 is the stack pointer):
test.ii.29.peephole2:
(jump_insn:HI 333 733 705 7 (set (pc)
(if_then_else (ne (reg:SI 147 t)
(const_int 0 [0x0]))
(label_ref 432)
(pc))) 195 {branch_true} (insn_list 332 (nil))
(expr_list:REG_DEAD (reg:SI 147 t)
(expr_list:REG_BR_PROB (const_int 7900 [0x1edc])
(nil))))
;; End of basic block 7, registers live:
1 [r1] 8 [r8] 9 [r9] 10 [r10] 11 [r11] 12 [r12] 15 [r15] 151 []
;; Register highparts live:
;; Start of basic block 8, registers live: 1 [r1] 8 [r8] 9 [r9] 10 [r10] 11 [r11] 12 [r12] 15 [r15] 151 []
;; register highparts live:
(note:HI 705 333 353 8 [bb 8] NOTE_INSN_BASIC_BLOCK)
(insn:HI 353 705 885 8 (set (reg/f:SI 15 r15)
(plus:SI (reg/f:SI 15 r15)
(const_int -4 [0xfffffffc]))) 39 {*addsi3_compact} (nil)
(nil))
(jump_insn 885 353 886 8 (set (pc)
(label_ref 884)) -1 (nil)
(nil))
;; End of basic block 8, registers live:
1 [r1] 8 [r8] 9 [r9] 10 [r10] 11 [r11] 12 [r12] 15 [r15] 151 []
**************************************************************************
test.ii.30.ce3:
(insn:HI 353 733 333 7 (set (reg/f:SI 15 r15)
(plus:SI (reg/f:SI 15 r15)
(const_int -4 [0xfffffffc]))) 39 {*addsi3_compact} (nil)
(nil))
(jump_insn:HI 333 353 899 7 (set (pc)
(if_then_else (eq (reg:SI 147 t)
(const_int 0 [0x0]))
(label_ref:SI 884)
(pc))) 196 {branch_false} (insn_list 332 (nil))
(expr_list:REG_DEAD (reg:SI 147 t)
(expr_list:REG_BR_PROB (const_int 2100 [0x834])
(nil))))
;; End of basic block 7, registers live:
1 [r1] 8 [r8] 9 [r9] 10 [r10] 11 [r11] 12 [r12] 15 [r15] 151 []
;; Register highparts live:
1 [r1] 8 [r8] 9 [r9] 10 [r10] 12 [r12] 15 [r15] 151 []
;; Start of basic block 8, registers live: 1 [r1] 8 [r8] 9 [r9] 10 [r10] 12 [r12] 15 [r15] 151 []
;; register highparts live:
(note 899 333 900 8 [bb 8] NOTE_INSN_BASIC_BLOCK)
(jump_insn 900 899 901 8 (set (pc)
(label_ref 432)) -1 (nil)
(nil))
;; End of basic block 8, registers live:
1 [r1] 8 [r8] 9 [r9] 10 [r10] 12 [r12] 15 [r15] 151 []
Currently regression testing on i686-px-linux-gnu X sh-elf and native.
2004-04-20 J"orn Rennecke <joern.rennecke@superh.com>
* flow.c (propagate_one_insn): Call mark_set_regs for stack pointer
updates too.
Index: flow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flow.c,v
retrieving revision 1.584
diff -p -r1.584 flow.c
*** flow.c 3 Mar 2004 11:41:47 -0000 1.584
--- flow.c 20 Apr 2004 15:12:57 -0000
*************** propagate_one_insn (struct propagate_blo
*** 1707,1718 ****
&& GET_CODE (SET_SRC (PATTERN (insn))) == PLUS
&& XEXP (SET_SRC (PATTERN (insn)), 0) == stack_pointer_rtx
&& GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == CONST_INT)
! /* We have an insn to pop a constant amount off the stack.
! (Such insns use PLUS regardless of the direction of the stack,
! and any insn to adjust the stack by a constant is always a pop.)
! These insns, if not dead stores, have no effect on life, though
! they do have an effect on the memory stores we are tracking. */
! invalidate_mems_from_set (pbi, stack_pointer_rtx);
else
{
rtx note;
--- 1707,1724 ----
&& GET_CODE (SET_SRC (PATTERN (insn))) == PLUS
&& XEXP (SET_SRC (PATTERN (insn)), 0) == stack_pointer_rtx
&& GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == CONST_INT)
! {
! /* We have an insn to pop a constant amount off the stack.
! (Such insns use PLUS regardless of the direction of the stack,
! and any insn to adjust the stack by a constant is always a pop
! or part of a push.)
! These insns, if not dead stores, have no effect on life, though
! they do have an effect on the memory stores we are tracking. */
! invalidate_mems_from_set (pbi, stack_pointer_rtx);
! /* Still, we need to update local_set, lest ifcvt.c:dead_or_predicable
! concludes that the stack pointer is not modified. */
! mark_set_regs (pbi, PATTERN (insn), insn);
! }
else
{
rtx note;