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

            Bug ID: 124956
           Summary: Improve conditional shift by 6 for leela on risc64
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: law at gcc dot gnu.org
  Target Milestone: ---

I haven't extracted the testcase (again, I've looked at this at least once
before in the past).  Consider this fragment from leela:

  0x0000000000027e3e   22565808364  1.1533% _ZN9FastState16play_random_moveEi
      sext.w                  a5,s2
      slliw                   s2,s2,6
      czero.eqz               a5,a5,a0
      czero.nez               a0,s2,a0
      add                     a0,a0,a5
      ld                      a5,16(sp)
      addw                    s9,a0,s9
      addiw                   s2,s1,1
      sw                      s11,-8(s6)
      sw                      s9,-4(s6)
      beq                     s2,a5,122               # 0x27edc

In particular note the sext+slliw+czero+czero+add sequence.  Conceptually what
we have is a conditional shift-by-6 with sign extension.  So we could generate
something like

      sext.w a5,s2
      li s2, 6
      czero.nez s2,s2,a0
      sllw a0,a5,s2


It's likely only a marginal (if any) improvement from a performance standpoint.
 But it does make the code smaller.

Reply via email to