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
this could actually be intentional. gcc tries to lay out the code so that forward conditional jumps are usually not taken, and it has a heuristic that numbers are usually non-negative. I am just guessing, though, there is really no way to tell what is happening without debugging the issue. To check whether this theory could be true, you can try changing the condition to "if (c > 0)", in which case the code should be generated the way you prefer, Zdenek