[Bug target/16494] New: [3.3.2/3.4/3.5] Pessimization with FP conditional branches

ebotcazou at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Jul 12 12:59:00 GMT 2004


On non-V9 targets, when delay slots are not filled, FP conditional branches are
unnecessarily reversed:

[eric@localhost obj.sparc]$ cat t.c
int foo(float f1, float f2)
{
  if (f1 > f2)
    return 0;
  else
    return 1;
}

[eric@localhost obj.sparc]$ gcc/cc1 -Bgcc t.c -mcpu=v7 -O2 -fno-delayed-branch
[eric@localhost obj.sparc]$ cat t.s
        .file   "t.c"
        .section        ".text"
        .align 4
        .global foo
        .type   foo, #function
        .proc   04
foo:
        !#PROLOGUE# 0
        add     %sp, -120, %sp
        !#PROLOGUE# 1
        st      %o0, [%sp+100]
        ld      [%sp+100], %f9
        st      %o1, [%sp+100]
        ld      [%sp+100], %f8
        fcmpes  %f9, %f8
        mov     0, %o0
        nop
        fbule   .+16
        nop
        b       .LL1
        nop
        mov     1, %o0
.LL1:
        retl
        sub     %sp, -120, %sp
        .size   foo, .-foo
        .ident  "GCC: (GNU) 3.3.5 20040703 (prerelease)"

The expected assembly output is:

        .file   "t.c"
        .section        ".text"
        .align 4
        .global foo
        .type   foo, #function
        .proc   04
foo:
        !#PROLOGUE# 0
        add     %sp, -120, %sp
        !#PROLOGUE# 1
        st      %o0, [%sp+100]
        ld      [%sp+100], %f9
        st      %o1, [%sp+100]
        ld      [%sp+100], %f8
        fcmpes  %f9, %f8
        mov     0, %o0
        nop
        fbg     .LL1
        nop
        mov     1, %o0
.LL1:
        retl
        sub     %sp, -120, %sp
        .size   foo, .-foo
        .ident  "GCC: (GNU) 3.3.5 20040703 (prerelease)"


This was inadvertently introduced by:

2003-10-01  Eric Botcazou  <ebotcazou@libertysurf.fr>

	PR optimization/11753
	* config/sparc/sparc.md (length attribute) [fcc branch]: Add 1 to
	the length in the non-V9 case.

because there is an undocumented side-effect associated with having a length
greater or equal to 3 for FP conditional branches.

-- 
           Summary: [3.3.2/3.4/3.5] Pessimization with FP conditional
                    branches
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ebotcazou at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-*-*
  GCC host triplet: sparc-*-*
GCC target triplet: sparc-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16494



More information about the Gcc-bugs mailing list