This is the mail archive of the gcc-bugs@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]

[Bug rtl-optimization/17482] GCSE after reload replacing changing instructions


------- Additional Comments From steven at gcc dot gnu dot org  2004-09-14 23:15 -------
David, 
 
I tried to reproduce this with a cross from amd64 to ppc-aix5.2, but 
unfortunately that didn't work.  What are the exact command line options you 
passes to the compiler? 
 
As I said in an earlier comment for this PR, I think mark_oprs_set just needs 
to be taught that autoincrements count as register modifying operations.  If I 
am right, the attached patch *should* fix the problem. 
But as I cannot reproduce the bug myself here so far, I cannot test the patch.  
Can you please give it a spin and see if it fixes the problem for you? 
 
Index: postreload-gcse.c 
=================================================================== 
RCS file: /cvs/gcc/gcc/gcc/postreload-gcse.c,v 
retrieving revision 2.4 
diff -c -3 -p -r2.4 postreload-gcse.c 
*** postreload-gcse.c   10 Sep 2004 11:02:26 -0000      2.4 
--- postreload-gcse.c   14 Sep 2004 23:05:24 -0000 
*************** oprs_unchanged_p (rtx x, rtx insn, bool 
*** 524,532 **** 
      case POST_INC: 
      case PRE_MODIFY: 
      case POST_MODIFY: 
!       if (after_insn) 
!       return 0; 
!       break; 
 
      default: 
        break; 
--- 524,530 ---- 
      case POST_INC: 
      case PRE_MODIFY: 
      case POST_MODIFY: 
!       return 0; 
 
      default: 
        break; 
*************** mark_clobber (rtx pat, rtx insn) 
*** 738,746 **** 
  static void 
  mark_oprs_set (rtx insn) 
  { 
!   rtx pat = PATTERN (insn); 
    int i; 
 
    if (GET_CODE (pat) == SET) 
      mark_set (pat, insn); 
 
--- 736,747 ---- 
  static void 
  mark_oprs_set (rtx insn) 
  { 
!   rtx pat, note; 
    int i; 
 
+   /* Look at the pattern to see what REGs and MEMs may be set 
+      by this insn.  */ 
+   pat = PATTERN (insn); 
    if (GET_CODE (pat) == SET) 
      mark_set (pat, insn); 
 
*************** mark_oprs_set (rtx insn) 
*** 762,767 **** 
--- 763,779 ---- 
 
    else if (GET_CODE (pat) == CALL) 
      mark_call (insn); 
+ 
+   /* Also record autoincremented REGs for this insn as changed.  */ 
+   for (note = REG_NOTES (insn); note; note = XEXP (note, 1)) 
+     { 
+       if (REG_NOTE_KIND (note) = REG_INC) 
+       { 
+         reg = XEXP (link, 0); 
+         gcc_assert (REG_P (reg)); 
+         record_last_reg_set_info (insn, REGNO (reg)); 
+       } 
+     } 
  } 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17482


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