Skip to content

[optimization] gcc generate better code than clang base on value range propagation #54735

Closed
@vfdff

Description

@vfdff

after fix the case #54132, the clang still need be improved for some more complex case (see detail on https://godbolt.org/z/xb9Mo85WM ), such as:

#include <stdlib.h>

int my_abs (int x, int y) {
  return x>y ? abs (x-y+1): 0;
}
  • clang's code:
my_abs: // @my_abs
  subs w8, w0, w1
  b.le .LBB0_2
  mvn w9, w8
  cmn w8, #1
  csinc w0, w9, w8, lt
  ret
.LBB0_2:
  mov w0, wzr
  ret
  • gcc's code:
my_abs:
  subs w0, w0, w1
  csinc w0, wzr, w0, le
  ret

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions