rs6000: Fix loop limit for built-in constant checking

Message ID 7d1a3cd4-bd2b-40c5-8aab-c503785c9da8@linux.ibm.com
State New
Headers
Series rs6000: Fix loop limit for built-in constant checking |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Test passed

Commit Message

Peter Bergner Jan. 10, 2025, 5:18 p.m. UTC
  FYI, I discovered this latent bug while testing a patch I'm working on.

The loop checking for built-in constant operand restrictions was missing
some operands due to the loop limit being too small.  Fixing that exposed
a testsuite failure which is caused by a typo in the pmxvi4ger8pp definition
where we had made the PMASK field too small.

Bootstrapped and retested on powerpc64le-linux with no regressions.
Ok for trunk and backports after some trunk burn-in time?

Peter


gcc/
	* config/rs6000/rs6000-builtin.cc (rs6000_expand_builtin): Use correct
	array size for the loop limit.
	* config/rs6000/rs6000-builtins.def: Fix field size for PMASK operand.
  

Comments

Peter Bergner Jan. 16, 2025, 4:57 p.m. UTC | #1
On 1/10/25 11:18 AM, Peter Bergner wrote:
> The loop checking for built-in constant operand restrictions was missing
> some operands due to the loop limit being too small.  Fixing that exposed
> a testsuite failure which is caused by a typo in the pmxvi4ger8pp definition
> where we had made the PMASK field too small.
> 
> Bootstrapped and retested on powerpc64le-linux with no regressions.
> Ok for trunk and backports after some trunk burn-in time?

Approved offline by Segher, so I pushed the commit.
I'll let it bake on trunk for a bit before backporting.

Peter
  

Patch

diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc
index bdf2fa0b680..0251a240b1a 100644
--- a/gcc/config/rs6000/rs6000-builtin.cc
+++ b/gcc/config/rs6000/rs6000-builtin.cc
@@ -3441,7 +3441,7 @@  rs6000_expand_builtin (tree exp, rtx target, rtx /* subtarget */,
     }
 
   /* Check for restricted constant arguments.  */
-  for (int i = 0; i < 2; i++)
+  for (size_t i = 0; i < ARRAY_SIZE (bifaddr->restr); i++)
     {
       switch (bifaddr->restr[i])
 	{
diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def
index 320049d8b0a..3ca63739d31 100644
--- a/gcc/config/rs6000/rs6000-builtins.def
+++ b/gcc/config/rs6000/rs6000-builtins.def
@@ -3687,11 +3687,11 @@ 
     PMXVI4GER8_INTERNAL mma_pmxvi4ger8 {mma}
 
   void __builtin_mma_pmxvi4ger8pp (v512 *, vuc, vuc, const int<4>, \
-                                   const int<4>, const int<4>);
+                                   const int<4>, const int<8>);
     PMXVI4GER8PP nothing {mma,quad,mmaint}
 
   v512 __builtin_mma_pmxvi4ger8pp_internal (v512, vuc, vuc, const int<4>, \
-                                            const int<4>, const int<4>);
+                                            const int<4>, const int<8>);
     PMXVI4GER8PP_INTERNAL mma_pmxvi4ger8pp {mma,quad}
 
   void __builtin_mma_pmxvi8ger4 (v512 *, vuc, vuc, const int<4>, \