------- Comment #6 from ubizjak at gmail dot com 2010-06-09 12:15 ------- Following patch is also needed to fix conditional splitting (it does not fix original uncovered problem where BLOCK_FOR_INSN returns null):
Index: i386.md =================================================================== --- i386.md (revision 160445) +++ i386.md (working copy) @@ -6087,8 +6087,15 @@ switch (get_attr_type (insn)) { case TYPE_LEA: - return "#"; + if (reload_completed && ix86_lea_for_add_ok (PLUS, insn, operands)) + return "#"; + gcc_assert (rtx_equal_p (operands[0], operands[2])); + if (x86_maybe_negate_const_int (&operands[1], <MODE>mode)) + return "sub{<imodesuffix>}\t{%1, %0|%0, %1}"; + + return "add{<imodesuffix>}\t{%1, %0|%0, %1}"; + case TYPE_INCDEC: gcc_assert (rtx_equal_p (operands[0], operands[1])); if (operands[2] == const1_rtx) @@ -6138,8 +6145,14 @@ switch (get_attr_type (insn)) { case TYPE_LEA: - return "#"; + if (reload_completed && ix86_lea_for_add_ok (PLUS, insn, operands)) + return "#"; + if (x86_maybe_negate_const_int (&operands[1], SImode)) + return "sub{l}\t{%1, %k0|%k0, %1}"; + + return "add{l}\t{%1, %k0|%k0, %1}"; + case TYPE_INCDEC: if (operands[2] == const1_rtx) return "inc{l}\t%k0"; @@ -6222,8 +6235,15 @@ switch (get_attr_type (insn)) { case TYPE_LEA: - return "#"; + if (reload_completed && ix86_lea_for_add_ok (PLUS, insn, operands)) + return "#"; + gcc_assert (rtx_equal_p (operands[0], operands[2])); + if (x86_maybe_negate_const_int (&operands[1], HImode)) + return "sub{w}\t{%1, %0|%0, %1}"; + + return "add{w}\t{%1, %0|%0, %1}"; + case TYPE_INCDEC: gcc_assert (rtx_equal_p (operands[0], operands[1])); if (operands[2] == const1_rtx) @@ -6313,8 +6333,22 @@ switch (get_attr_type (insn)) { case TYPE_LEA: - return "#"; + if (reload_completed && ix86_lea_for_add_ok (PLUS, insn, operands)) + return "#"; + gcc_assert (rtx_equal_p (operands[0], operands[2])); + if (x86_maybe_negate_const_int (&operands[1], QImode)) + { + if (widen) + return "sub{l}\t{%1, %k0|%k0, %1}"; + else + return "sub{b}\t{%1, %0|%0, %1}"; + } + if (widen) + return "add{l}\t{%k1, %k0|%k0, %k1}"; + else + return "add{b}\t{%1, %0|%0, %1}"; + case TYPE_INCDEC: gcc_assert (rtx_equal_p (operands[0], operands[1])); if (operands[2] == const1_rtx) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44470