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

            Bug ID: 106525
           Summary: s390: Inefficient branchless conditionals for unsigned
                    long long
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jens.seifert at de dot ibm.com
  Target Milestone: ---

Created attachment 53409
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53409&action=edit
source code

1)  -(a > b)

        clgr    %r2,%r3
        lhi     %r2,0
        alcr    %r2,%r2
        sllg    %r2,%r2,63
        srag    %r2,%r2,63

Last 2 could be merged to LCDFR. But optimal is:

        slgrk %r2,%r3,%r2
        slbgr %r2,%r2
        lgfr  %r2,%r2
Note: lgfr is not required => 2 instructions only.

2) -(a <= b)

        slgr    %r3,%r2
        lhi     %r2,0
        alcr    %r2,%r2
        sllg    %r2,%r2,63
        srag    %r2,%r2,63

Last 2 could be merged to LCDFR. But optimal is:

        clgr %r2,%r3
        slbgr %r2,%r2
        lgfr    %r2,%r2

Note: lgfr is not required => 2 instructions only.

3) unsigned 64-bit compare for qsort (a > b) - (a < b)

        clgr    %r2,%r3
        lhi     %r1,0
        alcr    %r1,%r1
        clgr    %r3,%r2
        lhi     %r2,0
        alcr    %r2,%r2
        srk     %r2,%r1,%r2
        lgfr    %r2,%r2

Optimal:
        slgrk %r1,%r2,%r3
        slgrk 0,%r3,%r2
        slbgr %r2,%r3
        slbgr %r1,%r2
        lgfr  %r2,%r1

Note: lgfr not required => 4 instructions only

Reply via email to