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

            Bug ID: 129163
           Summary: Use bext to extract bit on RISC-V
           Product: gcc
           Version: 17.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: ---

Consider:

int
f (int *p, int flags, int *q)
{
  int t = p[12];
  int s = t;
  if (flags & 4096)
    s = -t;
  *q = s;
  return __builtin_abs (s);
}


Generates:

        lw      a4,48(a0)
        li      a5,4096
        and     a1,a1,a5
        negw    t0,a4
        czero.eqz       t1,t0,a1
        czero.nez       t2,a4,a1
        add     a3,t2,t1
        negw    a0,a3
        sw      a3,0(a2)
        max     a0,a0,a3
        ret

The li+and is just a bitfield extraction.  It feeds a pair of czeros so that'd
be a 4->3 split, a no-go.  Seems like we should have generated better code
during expansion.

Reply via email to