This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

reverse conditionnal jump


Hi,

I'm still developping a new private target backend (gcc4.5.2) and I noticed something strange in the assembler generated for conditionnal jump.


The compiled C code source is :

void funct (int c) {
    int a;
    a = 7;
    if (c < 0)
      a = 4;
    return a;
}


The assembler generated is :

[...]
  mov 7,a
  cmp 0,c  #set the CC status
  jmpif LT .L2 #conditionnal jump using CC status
.L1
  ret a #return to callee
.L2
  mov 4,a
  jmp .L1 #unconditionnal jump


But, I was expecting only one jump as follow :

[...]
  mov 7,a
  cmp 0,c #set the CC status
  jmpif GE .L1 #conditionnal jump using CC status
  mov 4,a
.L1
  ret a #return to callee


All comparison are available and I defined REVERSIBLE_CC_MODE(MODE) to 1.

I also have the following branch insn (and the cbranchsi4 expand)

(define_insn "*jmpif"
  [(set (pc) 
        (if_then_else (match_operator 0 "comparison_operator"
          [(reg:CC CCI_REG) (const_int 0)])
        (label_ref (match_operand 1 "" ""))
        (pc)))]
""
"jmpif %c0 %l1"
)

(define_insn "*reverse_jmpif"
  [(set (pc) 
        (if_then_else (match_operator 0 "comparison_operator"
          [(reg:CC CCI_REG) (const_int 0)])
        (pc)
        (label_ref (match_operand 1 "" ""))))]
""
"jmpif %C0 %l1"
)


How can I tell GCC to perform the best conditionnal jump by sometimes reversing the comparison ?

   Regards,

     Selim



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]