Question about GCC code generation
pedward
Posts: 1,642
I was reviewing the code generated by GCC and I was struck by the complete lack of any conditional execution flags.
I see that GCC does the most simplistic IF_E conditional execution for if-then-else, but I haven't seen any other code that uses it.
I see that GCC does the most simplistic IF_E conditional execution for if-then-else, but I haven't seen any other code that uses it.
Comments
Could you give us an example of some code that you think should be compiled with conditional execution but isn't?
Thanks,
Eric
Dave, I-T-E was specifically exempted, since you can only code it (rationally) with conditional execution. You could use self modifying code, but that would just be masochistic!
I've never ported it to another processor but as I understood it, at its core it assumes a standard abstracted processor with a certain number of registers and certain basic instructions. Porting to a new processor is all about mapping those to the real target. Anything cleverer is handled by the optimisation phase and I'm not sure how easy it would be to spot where conditionals could be used. I suspect the amount of looking forwards and backwards over the basic code to see what could be optimised would make it rather tricky. But I might be wrong.
Pedward later qualified his question by saying "other than in if/then/else", but I have yet to figure out a case where the compiler should generate a conditional outside of if/then/else (or the C ? : operator, which GCC treats the same as if/then/else). That's not to say there isn't such a case, I'm just not aware of one.
Eric
The compiler would need to be an order of magnitude smarter to properly utilize alternate instructions and conditional execution. I don't know if GCC can do that nearly as well as a programmer.
One would probably need to sit down and think of all the clever ways to write ASM instructions and describe then to GCC in the RTL language it uses.