On 11/16/2021 10:20 PM, liuhongt via Gcc-patches wrote:
r12-5102-gfb161782545224f5 improves integer bit test on
__atomic_fetch_[or|and]_* returns only for nop_convert, .i.e.

transfrom

   mask_5 = 1 << bit_4(D);
   mask.0_1 = (unsigned int) mask_5;
   _2 = __atomic_fetch_or_4 (a_7(D), mask.0_1, 0);
   t1_9 = (int) _2;
   t2_10 = mask_5 & t1_9;

to

   mask_5 = 1 << n_4(D);
   mask.1_1 = (unsigned int) mask_5;
   _11 = .ATOMIC_BIT_TEST_AND_SET (&pscc_a_1_4, n_4(D), 0);
   _8 = (int) _11;

And this patch extend the original patch to handle truncation.
.i.e.

transform

   long int mask;
   mask_8 = 1 << n_7(D);
   mask.0_1 = (long unsigned int) mask_8;
   _2 = __sync_fetch_and_or_8 (&pscc_a_2_3, mask.0_1);
   _3 = (unsigned int) _2;
   _4 = (unsigned int) mask_8;
   _5 = _3 & _4;
   _6 = (int) _5;

to

   long int mask;
   mask_8 = 1 << n_7(D);
   mask.0_1 = (long unsigned int) mask_8;
   _14 = .ATOMIC_BIT_TEST_AND_SET (&pscc_a_2_3, n_7(D), 0);
   _5 = (unsigned int) _14;
   _6 = (int) _5;

Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}
Ok for trunk?

2021-11-17  Hongtao Liu  <hongtao....@intel.com>
            H.J. Lu  <hongjiu...@intel.com>

gcc/ChangeLog:

        PR tree-optimization/103194
        * match.pd (gimple_nop_atomic_bit_test_and_p): Extended to
        match truncation.
        * tree-ssa-ccp.c (gimple_nop_convert): Declare.
        (optimize_atomic_bit_test_and): Enhance
        optimize_atomic_bit_test_and to handle truncation.

gcc/testsuite/ChangeLog:

        * gcc.target/i386/pr103194-2.c: New test.
        * gcc.target/i386/pr103194-3.c: New test.
        * gcc.target/i386/pr103194-4.c: New test.
        * gcc.target/i386/pr103194-5.c: New test.
        * gcc.target/i386/pr103194.c: New test.
OK
jeff

Reply via email to