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

            Bug ID: 94927
           Summary: cortex-m7: Incorrect insn_reservation for
                    vmaxnm/vminnm instructions
           Product: gcc
           Version: 7.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stas.ibragimov at gmail dot com
  Target Milestone: ---

There is no any pipeline usage description for vmaxnm and vminnm instructions
in cortex-m7.md. This instruction is described as smax<mode>3 and smin<mode>3
in vfp.md and has type f_minmax<vfp_type>. But in cortex-m7.md there is not any
insn_reservations for this type. 

So, pipeline usage for code with this instructions is calculated wrong. 
For example:
//test.c
#include <math.h>
float test(int a, int b) {
        float max = fmaxf(a,b);
        float min = fminf(a,b);
        float x=min+1;
        return max/min-x;
}

Compile:
arm-none-eabi-gcc test.c -c -da -O3 -mcpu=cortex-m7 -mfpu=fpv5-d16
-mfloat-abi=hard -mthumb -ffinite-math-only -fno-signed-zeros -save-temps

test.c.293r.sched2 (wrong places is marked with (!!)):

;;        0--> b  0: i  24 s15=r0                                 
:cm7_i0|cm7_i1,cm7_a0|cm7_a1
;;        0--> b  0: i  12 s12=1.0e+0                             
:cm7_i0|cm7_i1,cm7_fpu
;;        2--> b  0: i   7 s14=flt(s15)                           
:cm7_i0|cm7_i1,cm7_fpu
;;        2--> b  0: i  25 s15=r1                                 
:cm7_i0|cm7_i1,cm7_a0|cm7_a1
;;        4--> b  0: i   8 s13=flt(s15)                           
:cm7_i0|cm7_i1,cm7_fpu
;;        7--> b  0: i   9 s15=smin(s14,s13)                       :nothing
(!!)
;;        7--> b  0: i  10 s14=smax(s14,s13)                       :nothing
(!!)
;;        8--> b  0: i  11 s0=s14/s15                             
:cm7_i0|cm7_i1,cm7_fpu*5
;;       13--> b  0: i  13 s15=s15+s12                            
:cm7_i0|cm7_i1,cm7_fpu
;;       24--> b  0: i  19 s0=s0-s15                              
:cm7_i0|cm7_i1,cm7_fpu
;;       24--> b  0: i  20 use s0                                  :nothing
;;       24--> b  0: i  28 simple_return                          
:cm7_i0|cm7_i1,cm7_branch

Reply via email to