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

            Bug ID: 100072
           Summary: [10/11 Regression] csel vs. csetm + and
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luc.vanoostenryck at gmail dot com
  Target Milestone: ---
            Target: aarch64

Created attachment 50587
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50587&action=edit
testcase

The following code:
    int sel_andn(int p, int a) { return (p ? ~0 : 0) & a; }
    int sel_andr(int p, int a) { return (p ? 0 : ~0) & a; }

translated to the following with GCC9 and before:
    sel_andn:
        cmp     w0, 0
        csel    w0, w1, wzr, ne
        ret
    sel_andr:
        cmp     w0, 0
        csel    w0, w1, wzr, eq
        ret

but since version 10 it translates into:
    sel_andn:
        cmp     w0, 0
        csetm   w0, ne
        and     w0, w0, w1
        ret
    sel_andr:
        cmp     w0, 0
        csetm   w0, eq
        and     w0, w0, w1
        ret

Same at https://gcc.godbolt.org/z/16fj1EYhx
  • [Bug target/100072] New: [... luc.vanoostenryck at gmail dot com via Gcc-bugs

Reply via email to