This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: SSA question
- From: Chris Lattner <sabre at nondot dot org>
- To: <law at redhat dot com>
- Cc: <gcc at gnu dot org>
- Date: Thu, 14 Mar 2002 13:11:58 -0600 (CST)
- Subject: Re: SSA question
> > Ok, if it's desired behavior, that's fine. :)
> I wouldn't go so far as to call it desirable :-) Just interesting. It
> wouldn't be that hard to convince me to rename it.
Ok, I didn't think it was desirable either. I think that renaming all
undefined incoming values should preserve the current semantics (that
undefined values are simply registers with no defs), with the added bonus
of breaking these loops.
Another "problem" I have with GCC's SSA (which is simply inconvenient) is
that there are situations where the number of incoming values for a PHI
node is != the number of predecessor basic blocks. For example:
int foo(int pred) {
int x;
if (pred) x = 12;
return x;
}
will generate a PHI node with one entry. I think that this should
actually be a PHI node with two incoming values, where one is undefined.
Should I look into doing this, or are the current semantics preferable?
> By renaming as you've suggested we could look up the definition of b and get
> null because the assignment to be was renamed.
Yup, I agree, I think renaming is the best way to go, and seems simple
enough.
> Go ahead and cobble up a patch, I'll review it.
Does this look reasonable? [My tree is very out of date, but it works for
me and should apply to a current tree with no problems]
--- ssa.c 19 Nov 2000 13:15:50 -0000 1.25
+++ ssa.c 14 Mar 2002 19:04:01 -0000
@@ -935,13 +935,21 @@
{
rtx new_reg = ssa_rename_to_lookup (x);
- if (new_reg != NULL_RTX && new_reg != RENAME_NO_RTX)
+ if (new_reg != RENAME_NO_RTX)
{
- if (GET_MODE (x) != GET_MODE (new_reg))
- abort ();
- *ptr = new_reg;
- }
- /* Else this is a use before a set. Warn? */
+ if (new_reg != NULL_RTX)
+ {
+ if (GET_MODE (x) != GET_MODE (new_reg))
+ abort ();
+ *ptr = new_reg;
+ }
+ else
+ {
+ /* Undefined value used, rename it to a new pseudo register so
+ that it cannot conflict with an existing register */
+ *ptr = gen_reg_rtx(GET_MODE(x));
+ }
+ }
}
return -1;
-Chris
http://www.nondot.org/~sabre/os/
http://www.nondot.org/MagicStats/