Hi all, Currently on arm we miss some opportunities to generate the cmn instruction (cmn r1, r2 ~ r1 + r2 == 0) For example, for code: int foo (int x, int y) { if (x + y == 0) return 25; else return 5; }
we generate add r0, r0, r1 cmp r0, #0 movne r0, #5 moveq r0, #25 This could be improved. During investigation I noticed that combine tries to transform x + y == 0 into x == -y, in RTL form: (eq (x) (neg y)) which is not the canonical form and therefore doesn't get matched by a pattern we have that would have produced a cmn instruction. Adding a re-canonicalization step in simplify_comparison fixes that and allows us to match the correct patterns. A new splitter is also added to arm that will allow us to produce forms appropriate for cmn when doing comparisons other than == in the case given above. Bootstrapped on arm-linux-gnueabihf and x86_64-linux-gnu. Regtested on arm-none-eabi on qemu. Ok for trunk? 2013-07-25 Kyrylo Tkachov <kyrylo.tkac...@arm.com> Richard Earnshaw <richard.earns...@arm.com> * combine.c (simplify_comparison): Re-canonicalize operands where appropriate. * config/arm/arm.md (movcond_addsi): New splitter.
generate_cmn.patch
Description: Binary data