Bug fix for consec_sets_giv
Bernd Schmidt
bernds@redhat.com
Mon Nov 20 04:39:00 GMT 2000
The function consec_sets_giv sets REG_IV_TYPE tentatively for the reg
it is examining. It does not reset it before returning; however, if it
returns a benefit of zero, we will not call record_giv for this register.
This means we end up with a garbage value in REG_IV_INFO. This showed up
as an infinite recursion when simplify_giv_expr tried to look up the
affected register.
Setting REG_IV_TYPE in this function can also clobber a previous value of
NOT_BASIC_INDUCT. The patch avoids this as well.
I'm currently testing this with an sh-elf compiler and a bootstrap on x86.
Bernd
* loop.c (consec_sets_giv): If the reg we're examining is anything
but UNKNOWN_INDUCT, do nothing.
Reset the reg's type to UNKNOWN_INDUCT before returning.
Index: loop.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/loop.c,v
retrieving revision 1.295
diff -u -p -r1.295 loop.c
--- loop.c 2000/11/13 22:20:02 1.295
+++ loop.c 2000/11/20 11:55:01
@@ -6203,8 +6203,12 @@ consec_sets_giv (loop, first_benefit, p,
general_induction_var below, so we can allocate it on our stack.
If this is a giv, our caller will replace the induct var entry with
a new induction structure. */
- struct induction *v
- = (struct induction *) alloca (sizeof (struct induction));
+ struct induction *v;
+
+ if (REG_IV_TYPE (ivs, REGNO (dest_reg)) != UNKNOWN_INDUCT)
+ return 0;
+
+ v = (struct induction *) alloca (sizeof (struct induction));
v->src_reg = src_reg;
v->mult_val = *mult_val;
v->add_val = *add_val;
@@ -6265,6 +6269,7 @@ consec_sets_giv (loop, first_benefit, p,
}
}
+ REG_IV_TYPE (ivs, REGNO (dest_reg)) = UNKNOWN_INDUCT;
*last_consec_insn = p;
return v->benefit;
}
More information about the Gcc-patches
mailing list