[PATCH, i386]: Split add insn to lea correctly
H.J. Lu
hjl.tools@gmail.com
Wed Jun 9 04:38:00 GMT 2010
On Mon, Jun 7, 2010 at 12:45 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> Attached patch removes a hack from add patterns, where lea insn was
> output directly from add patterns. This is not correct, since lea
> doesn't change flags. The patch changes add patterns to split relevant
We did that on purpose for -march=atom. It is OK since CC register
won't be used after add which clobbers CC register.
> add patterns to lea using existing splitters. This change uncovered a
> small problem, where ix86_gen_add3 generated nonexistent add pattern,
> where operand[0] != operand[1]. Lea handles this pattern just fine.
>
> The patch also removes ineffective alternative from add{si,di} pattern,
> since this alternative was shadowed by alternative 1. The patch also
> fixes a couple of inconsistencies, found by eyeballing lea patterns.
>
> 2010-06-07 Uros Bizjak <ubizjak@gmail.com>
>
> * config/i386/i386.md (*add<mode>_1): Remove alternative 2.
> <TYPE_LEA>: Split instruction.
> <default>: Remove alternative 2 handling.
> (*addsi_1_zext) <TYPE_LEA>: Split instruction.
> (add lea splitter): Generate SImode lea for mode sizes <= SImode.
> (add_zext lea splitter): Use ix86_lea_for_add_ok in insn predicate.
>
> (*movsi_1) <TYPE_LEA>: Use %a modifier to output operand 1.
> (ashift_zext lea splitter): Use DImode for multiplication.
>
> * config/i386/i386.c (ix86_expand_epilogue): Do not use ix86_gen_add
> to generate addition.
>
> Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
> {,-m32} and was committed to mainline.
>
> Last three changes will be backported to other release branches.
>
Basically it is OK to replace ADD with LEA if CC register is considered
clobbered. Do you have testcases for each issue you observed? I'd like to
restore Atom optimization to revision 160393 and fix the add/lea issues
you found at the same time.
Thanks.
--
H.J.
More information about the Gcc-patches
mailing list