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

Roger Sayle <roger at nextmovesoftware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |roger at nextmovesoftware dot 
com

--- Comment #2 from Roger Sayle <roger at nextmovesoftware dot com> ---
Hi Andrew,
I believe this missed-optimization is now implemented, and GCC generates the
same (or equivalent) code for all of:

int h1(int a, int b, int c, int d) {
  return (c & -(a==b)) | (d & -(a!=b));
}

int h2(int a, int b, int c, int d) {
  return (a==b) ? c : d;
}

int h3(int a, int b, int c, int d) {
  int t1 = a==b ? c : 0;
  int t2 = a==b ? 0 : d;
  return t1 | t2;
}

int h4(int a, int b, int c, int d) {
  int t1 = a==b ? c : 0;
  int t2 = a!=b ? d : 0;
  return t1 | t2;
}

If you agree we can close this PR.  I don't think this needs a new test case in
the testsuite, but I'll leave that up to you.

Reply via email to