On Tue, Jul 7, 2015 at 8:35 PM, Uros Bizjak <ubiz...@gmail.com> wrote:

> BT has *slightly* higher latency than TEST (0.33 vs. 0.25 cycles on a
> modern processor), so I have limited the conversion to -Os in case the
> bit-test is in the low 32 bits.

A small update, in case of -Os, unpatched compiler generates andb for
0 <= n <= 7 with:

  0:   83 e7 20                and    $0x20,%edi

vs.

  0:   0f ba e7 05             bt     $0x5,%edi

Attached patch updated the splitter condition to reflect the above.

2015-07-08  Uros Bizjak  <ubiz...@gmail.com>

    * config/i386/i386.md (*jcc_bt<mode>): Only allow const_int values
    more than or equal 8 and less than 32 when optimizing for size.

Tested on x86_64-linux-gnu {,-m32} and committed to mainline SVN.

Uros.

Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md (revision 225533)
+++ config/i386/i386.md (working copy)
@@ -10811,7 +10811,7 @@
   && (CONST_INT_P (operands[2])
       ? (INTVAL (operands[2]) < GET_MODE_BITSIZE (<MODE>mode)
         && INTVAL (operands[2])
-              >= (optimize_function_for_size_p (cfun) ? 0 : 32))
+              >= (optimize_function_for_size_p (cfun) ? 8 : 32))
       : register_operand (operands[2], SImode))
   && can_create_pseudo_p ()"
  "#"

Reply via email to