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

--- Comment #8 from Ken Young <selectstriker2 at protonmail dot com> ---
It seems to me that even if a naive decision tree is to be generated, it could
be done in a manner that simply checks for the case being equal and not do
anything with greater than

From:
.L9:
  cmpl $4, -4(%rbp)
  je .L2
  cmpl $4, -4(%rbp)
  jg .L3
  cmpl $3, -4(%rbp)
  je .L4
  cmpl $3, -4(%rbp)
  jg .L3            - already checked for ==4, >4, ==3 so >3 will always be
false
  cmpl $2, -4(%rbp)
  je .L5
  cmpl $2, -4(%rbp)
  jg .L3            - already checked for ==4, >4, ==3, ==2 so >2 will always
be false
  cmpl $0, -4(%rbp)
  je .L6
  cmpl $1, -4(%rbp)
  je .L7
  jmp .L3

To:

.L9:
  cmpl $4, -4(%rbp)
  je .L2
  cmpl $3, -4(%rbp)
  je .L4
  cmpl $2, -4(%rbp)
  je .L5
  cmpl $0, -4(%rbp)
  je .L6
  cmpl $1, -4(%rbp)
  je .L7
  jmp .L3

Reply via email to