https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96015

--- Comment #11 from Sergei Trofimovich <slyfox at inbox dot ru> ---
Looking at -fdump-tree-all:
    $gcc/xgcc -B$gcc -lm -Wsign-compare -Wall -fno-PIE -no-pie
-fno-stack-protector -O2 -S bug_test.c -o bad-bug.S -fdump-tree-all

I see that stores are eliminated at 'bad-bug.c.191t.cddce3' stage:

Was (at bad-bug.c.190t.dse3):

"""
__attribute__((noipa, noinline, noclone, no_icf))
long_richcompare (int * self, int * other, int op)
{
  int sign;
  int result;
  int _1;
  int _2;
  int _5;
  int prephitmp_6;
  int _13;
  int _16;

  <bb 2> [local count: 1073741823]:
  _1 = yes ();
  if (_1 == 0)
    goto <bb 11>; [51.12%]
  else
    goto <bb 3>; [48.88%]

  <bb 3> [local count: 524844999]:
  _2 = yes ();
  if (_2 == 0)
    goto <bb 11>; [34.00%]
  else
    goto <bb 4>; [66.00%]

  <bb 4> [local count: 346397698]:
  if (self_11(D) == other_12(D))
    goto <bb 7>; [30.00%]
  else
    goto <bb 5>; [70.00%]

  <bb 5> [local count: 242478389]:
  _13 = *self_11(D);
  _16 = *other_12(D);
  sign_17 = _13 - _16;
  if (sign_17 == 0)
    goto <bb 13>; [34.00%]
  else
    goto <bb 6>; [66.00%]

  <bb 6> [local count: 160035736]:
  goto <bb 13>; [100.00%]

  <bb 7> [local count: 103919309]:
  switch (op_14(D)) <default: <L12> [33.33%], case 0: <L6> [16.67%], case 1:
<L29> [33.33%], case 3: <L29> [33.33%], case 5: <L14> [16.67%]>

  <bb 8> [local count: 23093180]:
<L29>:
  goto <bb 12>; [100.00%]

  <bb 9> [local count: 115465900]:
  # prephitmp_6 = PHI <0(13), 1(7)>
<L6>:
  goto <bb 12>; [100.00%]

  <bb 10> [count: 0]:
<L12>:
  __builtin_unreachable ();

  <bb 11> [local count: 727344125]:

  <bb 12> [local count: 1073741824]:
  # _5 = PHI <0(13), prephitmp_6(9), 0(11), 0(8), 1(7)>
<L14>:
  return _5;

  <bb 13> [local count: 242478389]:
  # result_21 = PHI <1(5), sign_17(6)>
  switch (op_14(D)) <default: <L12> [33.33%], case 0: <L6> [16.67%], case 1:
<L14> [50.00%], case 3: <L14> [50.00%], case 5: <L14> [50.00%]>
}
"""

Became (at bad-bug.c.191t.cddce3):

"""
Removing basic block 5
__attribute__((noipa, noinline, noclone, no_icf))
long_richcompare (int * self, int * other, int op)
{
  int sign;
  int result;
  int _1;
  int _2;
  int _5;
  int prephitmp_6;

  <bb 2> [local count: 1073741823]:
  _1 = yes ();
  if (_1 == 0)
    goto <bb 9>; [51.12%]
  else
    goto <bb 3>; [48.88%]

  <bb 3> [local count: 524844999]:
  _2 = yes ();
  if (_2 == 0)
    goto <bb 9>; [34.00%]
  else
    goto <bb 4>; [66.00%]

  <bb 4> [local count: 346397698]:
  if (self_11(D) == other_12(D))
    goto <bb 5>; [30.00%]
  else
    goto <bb 11>; [70.00%]

  <bb 5> [local count: 103919309]:
  switch (op_14(D)) <default: <L12> [33.33%], case 0: <L6> [16.67%], case 1:
<L29> [33.33%], case 3: <L29> [33.33%], case 5: <L14> [16.67%]>

  <bb 6> [local count: 23093180]:
<L29>:
  goto <bb 10>; [100.00%]

  <bb 7> [local count: 115465900]:
  # prephitmp_6 = PHI <0(11), 1(5)>
<L6>:
  goto <bb 10>; [100.00%]

  <bb 8> [count: 0]:
<L12>:
  __builtin_unreachable ();

  <bb 9> [local count: 727344125]:

  <bb 10> [local count: 1073741824]:
  # _5 = PHI <0(11), prephitmp_6(7), 0(9), 0(6), 1(5)>
<L14>:
  return _5;

  <bb 11> [local count: 242478389]:
  switch (op_14(D)) <default: <L12> [33.33%], case 0: <L6> [16.67%], case 1:
<L14> [50.00%], case 3: <L14> [50.00%], case 5: <L14> [50.00%]>

}
"""


Note: the following block disappeared completely:
"""
  <bb 5> [local count: 242478389]:
  _13 = *self_11(D);
  _16 = *other_12(D);
"""

Reply via email to