On Sun, May 08, 2005 at 10:26:19PM +0200, Steven Bosscher wrote:
> Oops.  Not a modified tree, non-standard command line options:
> -O -fgcse --param max-cse-path-length=1

Ah, I see.  Well, I think this is a misfeature of gcse in how
it decides how to update expressions.  With a bit more thought
we could do better.

For instance, given

(insn 13 8 15 0 (set (reg/f:SI 121)
        (high:SI (symbol_ref:SI ("x") [flags 0x44] <var_decl 0xf7d5e3c0 x>)))
    218 {elf_high} (nil) (nil))

Register 121 used 1 times across 0 insns; set 1 time; dies in 0 places; pointer.

We can see that insn 13 dominates all uses of (high (symbol_ref x)),
so why don't we make *that* the reaching reg?

With something like this:

extern char *x;
void
foo (_Bool *p, char *a, char *b)
{
  int i;
  for (i = 0; i < 10; ++i)
    if (p[i])
      x[i] = a;
    else
      x[i] = b;
}

We get

PRE: redundant insn 36 (expression 3) in bb 3, reaching reg is 135
PRE: redundant insn 27 (expression 3) in bb 2, reaching reg is 135

LOCAL COPY-PROP: Replacing reg 130 in insn 29 with reg 135
LOCAL COPY-PROP: Replacing reg 133 in insn 38 with reg 135

GLOBAL CONST-PROP: Replacing reg 135 in insn 65 with
  constant (high:SI (symbol_ref:SI ("x") [flags 0x44] <var_decl 0xf7d5e3c0 x>))
GLOBAL CONST-PROP: Replacing reg 135 in insn 64 with
  constant (high:SI (symbol_ref:SI ("x") [flags 0x44] <var_decl 0xf7d5e3c0 x>))

but insns 64 and 65 are dead.  They were the copies from the reaching
reg 135 to the original regs 130 and 133, which COPY-PROP rightly
bypassed for us.

I guess it doesn't really matter that we did the CONST-PROP, but it's
certainly going to skew your statictics.  It would be surely be nice
if we could avoid this sort of thing, but I don't see how we can without
spending more cycles than we'd save.

I suppose for testing you could run a dce pass between COPY-PROP and
CONST-PROP, then see how much is left for CONST-PROP to do.  Perhaps
we can determine that it doesn't do enough to be worth running.  But
you're not going to be able to tell that easily right now.


r~

Reply via email to