public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/67998] New: redundant test for 0 when also checking inequality
@ 2015-10-16 21:31 rv at rasmusvillemoes dot dk
  2021-06-03  4:14 ` [Bug tree-optimization/67998] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: rv at rasmusvillemoes dot dk @ 2015-10-16 21:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67998
           Summary: redundant test for 0 when also checking inequality
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rv at rasmusvillemoes dot dk
  Target Milestone: ---

int f(unsigned a, unsigned b)
{
        if (!a || b >= a)
                return 5;
        return 2;
}

compiles to

f(unsigned int, unsigned int):
        testl   %edi, %edi
        je      .L3
        cmpl    %esi, %edi
        jbe     .L3
        movl    $2, %eax
        ret
.L3:
        movl    $5, %eax
        ret

The first test is redundant, since if a is zero, the inequality is guaranteed
to hold.


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

* [Bug tree-optimization/67998] redundant test for 0 when also checking inequality
  2015-10-16 21:31 [Bug tree-optimization/67998] New: redundant test for 0 when also checking inequality rv at rasmusvillemoes dot dk
@ 2021-06-03  4:14 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-03  4:14 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |12.0
      Known to fail|                            |7.1.0

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed already on the trunk, I have not tried any other version (except GCC 7
where it was still broken):
  <bb 2> [local count: 1073741824]:
  if (a_2(D) <= b_3(D))
    goto <bb 3>; [34.00%]
  else
    goto <bb 4>; [66.00%]

  <bb 3> [local count: 365072224]:

  <bb 4> [local count: 1073741824]:
  # _1 = PHI <5(3), 2(2)>

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

end of thread, other threads:[~2021-06-03  4:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-16 21:31 [Bug tree-optimization/67998] New: redundant test for 0 when also checking inequality rv at rasmusvillemoes dot dk
2021-06-03  4:14 ` [Bug tree-optimization/67998] " pinskia at gcc dot gnu.org

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