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

            Bug ID: 119164
           Summary: RISC-V: Extra FRM read/writes around call insns
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: target
          Assignee: vineetg at gcc dot gnu.org
          Reporter: vineetg at gcc dot gnu.org
                CC: law at gcc dot gnu.org, rdapp at gcc dot gnu.org
  Target Milestone: ---

With following test 

void *a;                        
float *b;
short c;
void d();
void e() {
  if (a)
    d();
  if (c) {
    b[0] = b[0] * 0.5f + 0.5f;
    b[1] = b[1] * 0.5f + 0.5f;
  }
}

And following toggles: -Ofast -march=rv64gcv_zvl256b_zba_zbb_zbs_zicond
-ftree-vectorize -mrvv-vector-bits=zvl

we get FRM save/restore around the call. 

e:
        lui     a5,%hi(a)
        ld      a5,%lo(a)(a5)
        addi    sp,sp,-32
        sd      ra,24(sp)
        frrm    a4              #55  <-----
        beq     a5,zero,.L2     #7
        sw      a4,12(sp)
        call    d               #9   <----
        lw      a4,12(sp)       
.L2:
        lui     a5,%hi(c)
        lh      a5,%lo(c)(a5)   #14
        beq     a5,zero,.L10
        fsrm    a4              #56  <-----
        lui     a5,%hi(b)
        ld      a4,%lo(b)(a5)
        lui     a5,%hi(.LANCHOR0)
        vsetivli        zero,2,e32,mf2,ta,ma
        addi    a5,a5,%lo(.LANCHOR0)
        vle32.v v1,0(a4)
        flw     fa5,0(a5)
        vfmv.v.f        v3,fa5    #49
        flw     fa5,4(a5)        #27
        vfmv.v.f        v2,fa5    #51


If we remove the condition around call, the f?rm insns disappear

-  if (a)
    d();

Reply via email to