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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Comparing the two patches, your patch handles f1-f4 in
/* PR target/92140 */

char c;
int v;

__attribute__((noipa)) void f1 (void) { v += c != 0; }
__attribute__((noipa)) void f2 (void) { v -= c != 0; }
__attribute__((noipa)) void f3 (void) { v += c == 0; }
__attribute__((noipa)) void f4 (void) { v -= c == 0; }
__attribute__((noipa)) void f5 (void) { v += (c != 0) - 26; }
__attribute__((noipa)) void f6 (void) { v -= (c != 0) - 26; }
__attribute__((noipa)) void f7 (void) { v += (c == 0) - 26; }
__attribute__((noipa)) void f8 (void) { v -= (c == 0) - 26; }
__attribute__((noipa)) void f9 (void) { v += (c != 0) + 42; }
__attribute__((noipa)) void f10 (void) { v -= (c != 0) + 42; }
__attribute__((noipa)) void f11 (void) { v += (c == 0) + 42; }
__attribute__((noipa)) void f12 (void) { v -= (c == 0) + 42; }
__attribute__((noipa)) void f13 (int z) { v += (c == 0) + z; }
__attribute__((noipa)) void f14 (int z) { v -= (c == 0) + z; }

int
main ()
{
  int i;
  for (i = 0; i < 2; i++)
    {
      v = 15;
      if (i == 1)
        c = 37;
      f1 ();
      if (v != 15 + i)
        __builtin_abort ();
      f2 ();
      if (v != 15)
        __builtin_abort ();
      f3 ();
      if (v != 16 - i)
        __builtin_abort ();
      f4 ();
      if (v != 15)
        __builtin_abort ();
      f5 ();
      if (v != 15 + i - 26)
        __builtin_abort ();
      f6 ();
      if (v != 15)
        __builtin_abort ();
      f7 ();
      if (v != 16 - i - 26)
        __builtin_abort ();
      f8 ();
      if (v != 15)
        __builtin_abort ();
      f9 ();
      if (v != 15 + i + 42)
        __builtin_abort ();
      f10 ();
      if (v != 15)
        __builtin_abort ();
      f11 ();
      if (v != 16 - i + 42)
        __builtin_abort ();
      f12 ();
      if (v != 15)
        __builtin_abort ();
      f13 (173);
      if (v != 16 - i + 173)
        __builtin_abort ();
      f14 (173);
      if (v != 15)
        __builtin_abort ();
      f13 (-35);
      if (v != 16 - i - 35)
        __builtin_abort ();
      f14 (-35);
      if (v != 15)
        __builtin_abort ();
    }
  return 0;
}
and all cases in the #c0 testcase, while my patch handles f1-f14 in the above
testcase and only tst1/tst2 in #c0 testcase.

For the pre-reload only splitters, I'm never sure if it is safe.  If it is
matched pre-split1 (usually during combine), it is of course fine, but what if
it appears after split1  and before end of reload, do we have a guarantee that
nothing will try to match those?  If it is safe, I can of course add the &&
!reload_completed or similar to the conditions (or && can_create_pseudo_p ()).

Reply via email to