[rs6000] Correct match pattern in pr56605.c

Message ID orcz4xgr2u.fsf@lxoliva.fsfla.org
State Committed
Commit 0580ea4b7a6dc8ee981b08f936b3ce62c6dfe200
Headers
Series [rs6000] Correct match pattern in pr56605.c |

Commit Message

Alexandre Oliva March 25, 2023, 8:42 a.m. UTC
  Ping https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590958.html

From: Haochen Gui <guihaoc@linux.ibm.com>

This patch corrects the match pattern in pr56605.c. The former pattern
is wrong and test case fails with GCC11. It should match following
insn on each subtarget after mode promotion is disabled. The patch
need to be backported to GCC11.

//gimple
_17 = (unsigned int) _20;
 prolog_loop_niters.4_23 = _17 & 3;

//rtl
(insn 19 18 20 2 (parallel [
            (set (reg:CC 208)
                (compare:CC (and:SI (subreg:SI (reg:DI 207) 0)
                        (const_int 3 [0x3]))
                    (const_int 0 [0])))
            (set (reg:SI 129 [ prolog_loop_niters.5 ])
                (and:SI (subreg:SI (reg:DI 207) 0)
                    (const_int 3 [0x3])))
        ]) 197 {*andsi3_imm_mask_dot2}

Rebased.  Regstrapped on ppc64-linux-gnu.  Also tested with
ppc64-vxworks7r2 (gcc-12), where it's also needed.  Ok to install?


for  gcc/testsuite/ChangeLog

	PR target/102146
	* gcc.target/powerpc/pr56605.c: Correct match pattern in
	combine pass.
---
 gcc/testsuite/gcc.target/powerpc/pr56605.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Kewen.Lin March 27, 2023, 7:41 a.m. UTC | #1
Hi Alexandre and Haochen,

on 2023/3/25 16:42, Alexandre Oliva via Gcc-patches wrote:
> 
> Ping https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590958.html
> 
> From: Haochen Gui <guihaoc@linux.ibm.com>
> 
> This patch corrects the match pattern in pr56605.c. The former pattern
> is wrong and test case fails with GCC11. It should match following
> insn on each subtarget after mode promotion is disabled. The patch
> need to be backported to GCC11.

Comment https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102146#c21 made me
feel that this test issue was just in branches, but this proposed patch
seems to say it still exists on trunk, could you confirm that?

BR,
Kewen

> 
> //gimple
> _17 = (unsigned int) _20;
>  prolog_loop_niters.4_23 = _17 & 3;
> 
> //rtl
> (insn 19 18 20 2 (parallel [
>             (set (reg:CC 208)
>                 (compare:CC (and:SI (subreg:SI (reg:DI 207) 0)
>                         (const_int 3 [0x3]))
>                     (const_int 0 [0])))
>             (set (reg:SI 129 [ prolog_loop_niters.5 ])
>                 (and:SI (subreg:SI (reg:DI 207) 0)
>                     (const_int 3 [0x3])))
>         ]) 197 {*andsi3_imm_mask_dot2}
> 
> Rebased.  Regstrapped on ppc64-linux-gnu.  Also tested with
> ppc64-vxworks7r2 (gcc-12), where it's also needed.  Ok to install?
> 
> 
> for  gcc/testsuite/ChangeLog
> 
> 	PR target/102146
> 	* gcc.target/powerpc/pr56605.c: Correct match pattern in
> 	combine pass.
> ---
>  gcc/testsuite/gcc.target/powerpc/pr56605.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/gcc/testsuite/gcc.target/powerpc/pr56605.c b/gcc/testsuite/gcc.target/powerpc/pr56605.c
> index 7695f87db6f66..651a88e3cc7f9 100644
> --- a/gcc/testsuite/gcc.target/powerpc/pr56605.c
> +++ b/gcc/testsuite/gcc.target/powerpc/pr56605.c
> @@ -11,5 +11,4 @@ void foo (short* __restrict sb, int* __restrict ia)
>      ia[i] = (int) sb[i];
>  }
>  
> -/* { dg-final { scan-rtl-dump-times {\(compare:CC \((?:and|zero_extend):(?:[SD]I) \((?:sub)?reg:[SD]I} 1 "combine" } } */
> -
> +/* { dg-final { scan-rtl-dump-times {\(compare:CC \(and:SI \(subreg:SI \(reg:DI} 1 "combine" } } */
  
HAO CHEN GUI March 27, 2023, 9:46 a.m. UTC | #2
Kewen,
  The case still fails with trunk.

FAIL: gcc.target/powerpc/pr56605.c scan-rtl-dump-times combine "\\(compare:CC \\((?:and|zero_extend):(?:[SD]I) \\((?:sub)?reg:[SD]I" 1

                === gcc Summary ===

# of expected passes            1
# of unexpected failures        1

  With the trunk, it should match the pattern.
(compare:CC (and:SI (subreg:SI (reg:DI 207) 0)

Thanks
Gui Haochen


在 2023/3/27 15:41, Kewen.Lin 写道:
> Hi Alexandre and Haochen,
> 
> on 2023/3/25 16:42, Alexandre Oliva via Gcc-patches wrote:
>>
>> Ping https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590958.html
>>
>> From: Haochen Gui <guihaoc@linux.ibm.com>
>>
>> This patch corrects the match pattern in pr56605.c. The former pattern
>> is wrong and test case fails with GCC11. It should match following
>> insn on each subtarget after mode promotion is disabled. The patch
>> need to be backported to GCC11.
> 
> Comment https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102146#c21 made me
> feel that this test issue was just in branches, but this proposed patch
> seems to say it still exists on trunk, could you confirm that?
> 
> BR,
> Kewen
> 
>>
>> //gimple
>> _17 = (unsigned int) _20;
>>  prolog_loop_niters.4_23 = _17 & 3;
>>
>> //rtl
>> (insn 19 18 20 2 (parallel [
>>             (set (reg:CC 208)
>>                 (compare:CC (and:SI (subreg:SI (reg:DI 207) 0)
>>                         (const_int 3 [0x3]))
>>                     (const_int 0 [0])))
>>             (set (reg:SI 129 [ prolog_loop_niters.5 ])
>>                 (and:SI (subreg:SI (reg:DI 207) 0)
>>                     (const_int 3 [0x3])))
>>         ]) 197 {*andsi3_imm_mask_dot2}
>>
>> Rebased.  Regstrapped on ppc64-linux-gnu.  Also tested with
>> ppc64-vxworks7r2 (gcc-12), where it's also needed.  Ok to install?
>>
>>
>> for  gcc/testsuite/ChangeLog
>>
>> 	PR target/102146
>> 	* gcc.target/powerpc/pr56605.c: Correct match pattern in
>> 	combine pass.
>> ---
>>  gcc/testsuite/gcc.target/powerpc/pr56605.c |    3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/gcc/testsuite/gcc.target/powerpc/pr56605.c b/gcc/testsuite/gcc.target/powerpc/pr56605.c
>> index 7695f87db6f66..651a88e3cc7f9 100644
>> --- a/gcc/testsuite/gcc.target/powerpc/pr56605.c
>> +++ b/gcc/testsuite/gcc.target/powerpc/pr56605.c
>> @@ -11,5 +11,4 @@ void foo (short* __restrict sb, int* __restrict ia)
>>      ia[i] = (int) sb[i];
>>  }
>>  
>> -/* { dg-final { scan-rtl-dump-times {\(compare:CC \((?:and|zero_extend):(?:[SD]I) \((?:sub)?reg:[SD]I} 1 "combine" } } */
>> -
>> +/* { dg-final { scan-rtl-dump-times {\(compare:CC \(and:SI \(subreg:SI \(reg:DI} 1 "combine" } } */
>
  
Kewen.Lin March 27, 2023, 10:25 a.m. UTC | #3
Hi Haochen,

on 2023/3/27 17:46, HAO CHEN GUI wrote:
> Kewen,
>   The case still fails with trunk.
> 

OK, thanks for checking, the proposed patch can catch the expected pattern
accurately (excluding noises), so okay for trunk and branches, thanks!

BR,
Kewen

> FAIL: gcc.target/powerpc/pr56605.c scan-rtl-dump-times combine "\\(compare:CC \\((?:and|zero_extend):(?:[SD]I) \\((?:sub)?reg:[SD]I" 1
> 
>                 === gcc Summary ===
> 
> # of expected passes            1
> # of unexpected failures        1
> 
>   With the trunk, it should match the pattern.
> (compare:CC (and:SI (subreg:SI (reg:DI 207) 0)
  

Patch

diff --git a/gcc/testsuite/gcc.target/powerpc/pr56605.c b/gcc/testsuite/gcc.target/powerpc/pr56605.c
index 7695f87db6f66..651a88e3cc7f9 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr56605.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr56605.c
@@ -11,5 +11,4 @@  void foo (short* __restrict sb, int* __restrict ia)
     ia[i] = (int) sb[i];
 }
 
-/* { dg-final { scan-rtl-dump-times {\(compare:CC \((?:and|zero_extend):(?:[SD]I) \((?:sub)?reg:[SD]I} 1 "combine" } } */
-
+/* { dg-final { scan-rtl-dump-times {\(compare:CC \(and:SI \(subreg:SI \(reg:DI} 1 "combine" } } */