public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/60554] redundant instruction is generated for setting the flags on x86
       [not found] <bug-60554-4@http.gcc.gnu.org/bugzilla/>
@ 2014-03-17 16:50 ` l_belev at yahoo dot com
  2014-03-17 17:08 ` l_belev at yahoo dot com
  1 sibling, 0 replies; 2+ messages in thread
From: l_belev at yahoo dot com @ 2014-03-17 16:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60554

--- Comment #1 from Luchezar Belev <l_belev at yahoo dot com> ---
since all (x^0x80000000), (x+0x80000000) and (x-0x80000000) are equivalend in
this case, if GCC had used the subtraction (instead of the addition) it could
optimize the code even further by considering the fact that intermediate result
is not needed and use cmpl instead of subl:

_is_float_negative:
   cmpl $0x80000000, 4(%esp)
   setg %al
   movzbl %al, %eax
   ret

which is the same as if the function was written as
 int is_float_negative(int x) { return (unsigned)x > 0x80000000; }


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug rtl-optimization/60554] redundant instruction is generated for setting the flags on x86
       [not found] <bug-60554-4@http.gcc.gnu.org/bugzilla/>
  2014-03-17 16:50 ` [Bug rtl-optimization/60554] redundant instruction is generated for setting the flags on x86 l_belev at yahoo dot com
@ 2014-03-17 17:08 ` l_belev at yahoo dot com
  1 sibling, 0 replies; 2+ messages in thread
From: l_belev at yahoo dot com @ 2014-03-17 17:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60554

--- Comment #2 from Luchezar Belev <l_belev at yahoo dot com> ---
sorry, the above code to be correct "setg %al" should be "seta %al" instead.

also in the compiler-generated code, the testl instruction is still redundant,
but when it is removed the following "setg %al" should be replaced with "seta
%al".
Maybe this is too complicated for a compiler to figure out though.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-17 17:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-60554-4@http.gcc.gnu.org/bugzilla/>
2014-03-17 16:50 ` [Bug rtl-optimization/60554] redundant instruction is generated for setting the flags on x86 l_belev at yahoo dot com
2014-03-17 17:08 ` l_belev at yahoo dot com

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).