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]

FRV-specific ifcvt bug


I've run into a bug in FRV-specific utility functions.  Basically, the
failing scenario was that, given a pair of nested ifs, both of which
had been successfully converted, the first one introduced a load of a
constant into a scratch register, but it turned out that the else
branch of the enclosing if needed that register live.  The problem was
that the code that attempted to avoid making such
constant-to-scratch-reg loads conditional (because then they'd need
yet another scratch register, since there isn't a conditional
instruction that loads an immediate to a register) didn't take this
possibility into account.

Richard Henderson reviewed an earlier version of the patch, and agreed
with the general idea but requested some simplifications.  Here's the
final form.  Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* config/frv/frv.c (insn_in_bb_p): Remove.
	(frv_ifcvt_modify_insn): Simplify previous change.

Index: gcc/config/frv/frv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.c,v
retrieving revision 1.41
diff -u -p -r1.41 frv.c
--- gcc/config/frv/frv.c 13 Dec 2003 04:44:05 -0000 1.41
+++ gcc/config/frv/frv.c 17 Dec 2003 15:35:16 -0000
@@ -6942,7 +6942,7 @@ single_set_pattern (rtx pattern)
    insn cannot be converted to be executed conditionally.  */
 
 rtx
-frv_ifcvt_modify_insn (ce_if_block_t *ce_info ATTRIBUTE_UNUSED,
+frv_ifcvt_modify_insn (ce_if_block_t *ce_info,
                        rtx pattern,
                        rtx insn)
 {
@@ -7068,7 +7068,16 @@ frv_ifcvt_modify_insn (ce_if_block_t *ce
          other registers.  */
       else if (frv_ifcvt.scratch_insns_bitmap
 	       && bitmap_bit_p (frv_ifcvt.scratch_insns_bitmap,
-				INSN_UID (insn)))
+				INSN_UID (insn))
+	       /* We must not unconditionally set a reg set used as
+		  scratch in the THEN branch if the same reg is live
+		  in the ELSE branch.  */
+	       && REG_P (SET_DEST (set))
+	       && (! ce_info->else_bb
+		   || BLOCK_FOR_INSN (insn) == ce_info->else_bb
+		   || ! (REGNO_REG_SET_P
+			 (ce_info->else_bb->global_live_at_start,
+			  REGNO (SET_DEST (set))))))
 	pattern = set;
 
       else if (mode == QImode || mode == HImode || mode == SImode
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer

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