Skip to content

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

@vfdff

Description

@vfdff
  • test case:
    int my_abs (int x, int y) { return x>y ? abs (x-y) + y: 0; }
  • clang's code, which need more optimization
my_abs: // @my_abs
  subs w8, w0, w1
  b.le .LBB0_2
  cmp w8, #0
  cneg w8, w8, mi
  add w0, w8, w1
  ret
.LBB0_2:
  mov w0, wzr
  ret

Compared to gcc, clang produces slightly more verbose code for a sequence, see detail https://godbolt.org/z/en7Mqcd7v

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