This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch] fix for loop optimizer (strength reduction)
- To: <gcc-patches at gcc dot gnu dot org>
- Subject: [Patch] fix for loop optimizer (strength reduction)
- From: "Jose Luu" <jluu at mainsoft dot com>
- Date: Thu, 20 Jan 2000 19:44:28 +0100
Please someone integrate, since I dont have write access.
Bug report and test case:
http://gcc.gnu.org/ml/gcc-bugs/2000-01/msg00526.html
When a giv (global induction variable) is used before its initial assignment
is is not correct to allow replacement by the strength reduced variable, I
added the code to detect this condition in function record_giv.
Previously, this condition was caught later in the case of for loops (or
when the biv is incremented before the giv) by the code in
check_final_value, I think that's why this problem went undetected so far.
ChangeLog
2000-01-20 Jose Luu (jluu@mainsoft.com)
gcc/loop.c (record_giv): detect if the giv is used before its
assignment, assert not_replaceable in this case.
Index: loop.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/loop.c,v
retrieving revision 1.216
diff -c -3 -p -r1.216 loop.c
*** loop.c 2000/01/05 06:55:01 1.216
--- loop.c 2000/01/20 18:14:21
*************** record_giv (v, insn, src_reg, dest_reg,
*** 5764,5769 ****
--- 5764,5786 ----
}
}
+ /* giv is not repleaceable if its initial value is used in the loop
before
+ the assignment */
+ if (!v->not_replaceable) {
+ rtx p = loop_start;
+ while (p != v->insn) {
+ if ((GET_CODE (p) == INSN || GET_CODE (p) == JUMP_INSN
+ || GET_CODE (p) == CALL_INSN) &&
+ (reg_mentioned_p (v->dest_reg, PATTERN (p))))
+ {
+ v->replaceable = 0;
+ v->not_replaceable = 1;
+ break;
+ }
+ p = NEXT_INSN (p);
+ }
+ }
+
/* Record whether the add_val contains a const_int, for later use by
combine_givs. */
{