[PATCH, i386]: Further ADD/LEA improvements

H.J. Lu hjl.tools@gmail.com
Thu Aug 19 01:38:00 GMT 2010


On Wed, Aug 18, 2010 at 12:32 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> Hello!
>
> Attached patch splits three-operand ADD instructions to clobber-less
> LEA rtx and further improves a couple of add patterns. It also
> introduces the same LEA avoidance alternatives to addsi_1_zext,
> addhi_1_lea and addqi_1_lea patterns as were already introduced to
> add{si,di}_1.
>
> 2010-08-18  Uros Bizjak  <ubizjak@gmail.com>
>
>        * config/i386/i386.md (*add<mode>_1) <TYPE_LEA>: Split insn to lea.
>        <default>:  Swap operands 1 and 2 for alternative 2 to use existing
>        code to output insn mnemonic.  Fix comment.
>        (*addsi_1_zext): Add r-r-0 alternative 1.
>        <TYPE_LEA>: Split insn to lea.
>        <default>: Handle alternative 1.
>        (*addhi_1_lea): Add r-r-0 alternative 2.  Use cond RTX instead of
>        multi-level if_then_else RTX to set "type" attribute.
>        <default>: Handle alternative 2.
>        (*addqi_1_lea): Add q-q-0 alternative 2 and r-r-0 alternative 4.
>        Use cond RTX instead of multi-level if_then_else RTX to set
>        "type" attribute.
>        <default>: Handle alternatives 2 and 4.
>        (lea splitters): Update calls to ix86_lea_for_add_ok.
>
>        * config/i386/i386.c (ix86_lea_for_add_ok): Remove unused "code"
>        argument.
>        * config/i386/i386-protos.h (ix86_lea_for_add_ok): Update prototype.
>
> Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu
> {,-m32} with and without --with-cpu=atom configure option. Committed
> to SVN mainline.
>

I took another look. When we added Atom optimization, we changed condition
of DI/SI LEA split patterns from

&& true_regnum (operands[0]) != true_regnum (operands[1])"

to

&& ix86_lea_for_add_ok (PLUS, insn, operands)"

The current ix86_lea_for_add_ok has

  unsigned int regno0 = true_regnum (operands[0]);
  unsigned int regno1 = true_regnum (operands[1]);
  unsigned int regno2 = true_regnum (operands[2]);

  /* If a = b + c, (a!=b && a!=c), must use lea form. */
  if (regno0 != regno1 && regno0 != regno2)
    return true;

  if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun))
    return false;

Otherwise, you won't get ADD. We may need to add

&& true_regnum (operands[0]) != true_regnum (operands[2])"

to other LEA split patterns.


-- 
H.J.



More information about the Gcc-patches mailing list