[Bug target/45434] x86 missed optimization: use high register (ah, bh, ch, dh) when available to make comparisons

2024-01-17 Thread ubizjak at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45434

--- Comment #9 from Uroš Bizjak  ---
The current mainline compiles:

--cut here--
_Bool foo(int i)
{
  return (i & 0xFF) == ((i & 0xFF00) >> 8);
}

_Bool bar(int i)
{
  return (i & 0xFF) <= ((i & 0xFF00) >> 8);
}
--cut here--

with -O2 to:

foo:
movl%edi, %eax
sarl$8, %eax
xorl%edi, %eax
testb   %al, %al
sete%al
ret

bar:
movl%edi, %eax
cmpb%al, %ah
setnb   %al
ret

While ._original dump reads:

;; Function foo (null)

{
  return ((i >> 8 ^ i) & 255) == 0;
}


;; Function bar (null)

{
  return (i & 255) <= (i >> 8 & 255);
}

The test for equivalence goes through XOR which interferes with the ability of
the combine pass to form the compare with zero-extracted argument RTX.

[Bug target/45434] x86 missed optimization: use high register (ah, bh, ch, dh) when available to make comparisons

2021-08-14 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45434

Andrew Pinski  changed:

   What|Removed |Added

  Component|rtl-optimization|target
 Target||i?86-*-* x86_64-*-*
   Severity|minor   |enhancement
   Keywords||missed-optimization