public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Should warning of -Wunreachable-code be generated when optimization   is taken?
@ 2009-10-28 13:47 Eric Fisher
  0 siblings, 0 replies; only message in thread
From: Eric Fisher @ 2009-10-28 13:47 UTC (permalink / raw)
  To: gcc

Hi,

I run into such an XPASS for trunck. And it seems an old problem.

XPASS: gcc.dg/Wunreachable-8.c  (test for bogus messages, line 7)

/* { dg-do compile } */
/* { dg-options "-O2 -Wunreachable-code" } */
float Factorial(float X)
{
  float val = 1.0;
  int k,j;
  for (k=1; k < 5; k++) /* { dg-bogus "will never be executed" "" {
xfail *-*-* } } */
    {
      val += 1.0; /* { dg-bogus "will never be executed" "" { xfail *-*-* } } */
    }
  return (val); /* { dg-bogus "will never be executed" } */
}

The warning is generated during remove_bb <bb 3> in
pass_complete_unrolli. It's odd that after complete unrolling, there
is one redundant iteration bb.

(gdb) p debug_function (current_function_decl,1)
Factorial (float X)
{
  int k;
  float val;

<bb 2>:

<bb 7>:
  val_10 = 2.0e+0;
  k_11 = 2;

<bb 8>:
  # val_12 = PHI <val_10(7)>
  # k_13 = PHI <k_11(7)>

<bb 9>:
  val_14 = val_12 + 1.0e+0;
  k_15 = k_13 + 1;

<bb 10>:
  # val_16 = PHI <val_14(9)>
  # k_17 = PHI <k_15(9)>

<bb 11>:
  val_18 = val_16 + 1.0e+0;
  k_19 = k_17 + 1;

<bb 12>:
  # val_20 = PHI <val_18(11)>
  # k_21 = PHI <k_19(11)>

<bb 13>:
  val_22 = val_20 + 1.0e+0;
  k_23 = k_21 + 1;
  goto <bb 4>;

<bb 3>:
  val_5 = val_1 + 1.0e+0;
  k_6 = k_2 + 1;

<bb 4>:
Invalid sum of outgoing probabilities 180.0%
Invalid sum of incoming frequencies 3600, should be 2000
  # val_1 = PHI <val_22(13), val_5(3)>
  # k_2 = PHI <k_23(13), k_6(3)>
  if (1 == 0)
    goto <bb 3>;
  else
    goto <bb 5>;

<bb 5>:
  return val_1;

}

Regards,
Eric

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-10-28  8:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-28 13:47 Should warning of -Wunreachable-code be generated when optimization is taken? Eric Fisher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).