This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PRs 56957 and 57105


Hello,

After Steven's changes tightening the add/remove insn interface, we found a problem in the selective scheduling when we incorrectly determined whether an insn should be removed (and a fresh one emitted) or just moved to a scheduling point. Fixed by just comparing INSN_UIDs of the insn below and the chosen expr above and abandoning other too clever code for checking whether an insn was changed or extra insns were emitted.

Some extra cleanups are possible after this patch, but I'd wait a bit to see if there is any fallout first.

Bootstrapped and tested on ia64 and x86-64, committed after offline approval from Alexander.

Andrey

2013-04-30  Andrey Belevantsev  <abel@ispras.ru>

	gcc:

        PR rtl-optimization/56957
        PR rtl-optimization/57105
	* sel-sched.c (move_op_orig_expr_found): Remove insn_emitted
        variable.  Use just INSN_UID for determining whether an insn
        should be only disconnected from the insn stream.
        * sel-sched-ir.h (EXPR_WAS_CHANGED): Remove.

	gcc/testsuite:

        PR rtl-optimization/57105
	* gcc.dg/pr57105.c: New test.
Index: gcc/ChangeLog
===================================================================
*** gcc/ChangeLog	(revision 198448)
--- gcc/ChangeLog	(revision 198449)
***************
*** 1,3 ****
--- 1,13 ----
+ 2013-04-30  Andrey Belevantsev  <abel@ispras.ru>
+ 
+ 	PR rtl-optimization/56957
+ 	PR rtl-optimization/57105
+ 
+ 	* sel-sched.c (move_op_orig_expr_found): Remove insn_emitted
+ 	variable.  Use just INSN_UID for determining whether an insn
+ 	should be only disconnected from the insn stream.
+ 	* sel-sched-ir.h (EXPR_WAS_CHANGED): Remove.
+ 
  2013-04-30  Jakub Jelinek  <jakub@redhat.com>
  
  	PR tree-optimization/57104
Index: gcc/testsuite/gcc.dg/pr57105.c
===================================================================
*** gcc/testsuite/gcc.dg/pr57105.c	(revision 0)
--- gcc/testsuite/gcc.dg/pr57105.c	(revision 198449)
***************
*** 0 ****
--- 1,18 ----
+ /* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
+ /* { dg-options "-Os -fselective-scheduling2 -g" } */
+ int bar (int);
+ int *baz (int *);
+ 
+ void
+ foo (int a)
+ {
+   while (bar (0))
+     {
+       int *c = baz (0);
+       if (a)
+ 	{
+ 	  int i = *baz (c);
+ 	}
+       bar (*baz (c));
+     }
+ }
Index: gcc/testsuite/ChangeLog
===================================================================
*** gcc/testsuite/ChangeLog	(revision 198448)
--- gcc/testsuite/ChangeLog	(revision 198449)
***************
*** 1,3 ****
--- 1,8 ----
+ 2013-04-30  Andrey Belevantsev  <abel@ispras.ru>
+ 
+ 	PR rtl-optimization/57105
+ 	* gcc.dg/pr57105.c: New test.
+ 
  2013-04-30  Jakub Jelinek  <jakub@redhat.com>
  
  	PR tree-optimization/57104
Index: gcc/sel-sched.c
===================================================================
*** gcc/sel-sched.c	(revision 198448)
--- gcc/sel-sched.c	(revision 198449)
*************** move_op_orig_expr_found (insn_t insn, ex
*** 6051,6064 ****
                           cmpd_local_params_p lparams ATTRIBUTE_UNUSED,
                           void *static_params)
  {
!   bool only_disconnect, insn_emitted;
    moveop_static_params_p params = (moveop_static_params_p) static_params;
  
    copy_expr_onside (params->c_expr, INSN_EXPR (insn));
    track_scheduled_insns_and_blocks (insn);
!   insn_emitted = handle_emitting_transformations (insn, expr, params);
!   only_disconnect = (params->uid == INSN_UID (insn)
!                      && ! insn_emitted  && ! EXPR_WAS_CHANGED (expr));
  
    /* Mark that we've disconnected an insn.  */
    if (only_disconnect)
--- 6051,6063 ----
                           cmpd_local_params_p lparams ATTRIBUTE_UNUSED,
                           void *static_params)
  {
!   bool only_disconnect;
    moveop_static_params_p params = (moveop_static_params_p) static_params;
  
    copy_expr_onside (params->c_expr, INSN_EXPR (insn));
    track_scheduled_insns_and_blocks (insn);
!   handle_emitting_transformations (insn, expr, params);
!   only_disconnect = params->uid == INSN_UID (insn);
  
    /* Mark that we've disconnected an insn.  */
    if (only_disconnect)
Index: gcc/sel-sched-ir.h
===================================================================
*** gcc/sel-sched-ir.h	(revision 198448)
--- gcc/sel-sched-ir.h	(revision 198449)
*************** typedef expr_def *expr_t;
*** 191,198 ****
  #define EXPR_WAS_RENAMED(EXPR) ((EXPR)->was_renamed)
  #define EXPR_CANT_MOVE(EXPR) ((EXPR)->cant_move)
  
- #define EXPR_WAS_CHANGED(EXPR) (EXPR_HISTORY_OF_CHANGES (EXPR).length () > 0)
- 
  /* Insn definition for list of original insns in find_used_regs.  */
  struct _def
  {
--- 191,196 ----

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]