diff options
author | liuhongt <hongtao.liu@intel.com> | 2021-12-07 15:41:52 +0800 |
---|---|---|
committer | liuhongt <hongtao.liu@intel.com> | 2022-05-18 15:46:21 +0800 |
commit | 9d1336d977cf0cab75679d4b4170e7c9a86cd1f4 (patch) | |
tree | 374f3e3a39dacb7097ddb27370329b1a60258f3b /gcc/match.pd | |
parent | a174dc1a7f2bf0a71475ff633b130a60c0c3ff4a (diff) | |
download | gcc-9d1336d977cf0cab75679d4b4170e7c9a86cd1f4.zip gcc-9d1336d977cf0cab75679d4b4170e7c9a86cd1f4.tar.gz gcc-9d1336d977cf0cab75679d4b4170e7c9a86cd1f4.tar.bz2 |
Enhance final_value_replacement_loop to handle bitwise induction.
This patch will enable below optimization:
{
- int bit;
- long long unsigned int _1;
- long long unsigned int _2;
-
<bb 2> [local count: 46707768]:
-
- <bb 3> [local count: 1027034057]:
- # tmp_11 = PHI <tmp_8(3), tmp_6(D)(2)>
- # bit_13 = PHI <bit_9(3), 63(2)>
- _1 = 1 << bit_13;
- _2 = ~_1;
- tmp_8 = _2 & tmp_11;
- bit_9 = bit_13 + -3;
- if (bit_9 != -3(OVF))
- goto <bb 3>; [95.65%]
- else
- goto <bb 4>; [4.35%]
-
- <bb 4> [local count: 46707768]:
- return tmp_8;
+ tmp_12 = tmp_6(D) & 7905747460161236406;
+ return tmp_12;
}
gcc/ChangeLog:
PR middle-end/103462
* match.pd (bitwise_induction_p): New match.
* tree-scalar-evolution.cc (gimple_bitwise_induction_p):
Declare.
(analyze_and_compute_bitwise_induction_effect): New function.
(enum bit_op_kind): New enum.
(final_value_replacement_loop): Enhanced to handle bitwise
induction.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr103462-1.c: New test.
* gcc.target/i386/pr103462-2.c: New test.
* gcc.target/i386/pr103462-3.c: New test.
* gcc.target/i386/pr103462-4.c: New test.
* gcc.target/i386/pr103462-5.c: New test.
* gcc.target/i386/pr103462-6.c: New test.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 0995055..c2fed9b 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7828,3 +7828,13 @@ and, == TYPE_UNSIGNED (TREE_TYPE (@3)))) && single_use (@4) && single_use (@5)))) + +(for bit_op (bit_and bit_ior bit_xor) + (match (bitwise_induction_p @0 @2 @3) + (bit_op:c + (nop_convert1? (bit_not2?@0 (convert3? (lshift integer_onep@1 @2)))) + @3))) + +(match (bitwise_induction_p @0 @2 @3) + (bit_not + (nop_convert1? (bit_xor@0 (convert2? (lshift integer_onep@1 @2)) @3)))) |