This is the mail archive of the gcc@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]

Re: gcc/1532: Redundant compare instructions on i386


In message <m3ektuknh6.fsf@gossamer.airs.com>, Ian Lance Taylor writes:
 >Hmmm, that's true, but also the machine dependent reorg pass is so
 >late in the process.  It would be nice to do this before reload, at
 >least, since it can potentially free up a register which won't be
 >needed for the second compare.  Admittedly you can't do any math,
 >since that would clobber the flags register, but you can at least move
 >stuff around.  I dunno.  Maybe it won't make any difference in
 >practice.
FYI -- here's what I get out of the tree-ssa optimizers for that testcase
with a trivial tweak to the jump threading code:


foo (i, j)
{
  int <D1081>;
                                                                               

  # BLOCK 0
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  if (i == j) goto <L9>; else goto <L1>;
  # SUCC: 2 [71.0%]  (false,exec) 1 [29.0%]  (true,exec)
                                                                               

  # BLOCK 1
  # PRED: 0 [29.0%]  (true,exec)
<L9>:;
  return j + j;
  # SUCC: EXIT [100.0%]
                                                                               

  # BLOCK 2
  # PRED: 0 [71.0%]  (false,exec)
<L1>:;
  if (i > j) goto <L2>; else goto <L10>;
  # SUCC: 3 [50.0%]  (false,exec) 4 [50.0%]  (true,exec)
                                                                               

  # BLOCK 3
  # PRED: 2 [50.0%]  (false,exec)
<L10>:;
  return j;
  # SUCC: EXIT [100.0%]
                                                                               

  # BLOCK 4
  # PRED: 2 [50.0%]  (true,exec)
<L2>:;
  return i;
  # SUCC: EXIT [100.0%]
                                                                               

}


Note how the switch statement has been eliminated.

I won't be able to run through a regression test tonight (already got
something running), but I'll do it tomorrow.  I don't expect any problems.

jeff


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