[committed] pru: Handle vector modes in CLZ_DEFINED_VALUE_AT_ZERO

Message ID 20261011165457.716358-1-dimitar@dinux.eu
State Committed
Commit 6ae2ad3169ab88823d288082a9058c3bf6db40fd
Headers
Series [committed] pru: Handle vector modes in CLZ_DEFINED_VALUE_AT_ZERO |

Commit Message

Dimitar Dimitrov Oct. 11, 2026, 4:54 p.m. UTC
  Commit r17-5047-gd2e1b1248a17d0 started passing the vector mode instead
of scalar mode to CLZ_DEFINED_VALUE_AT_ZERO.  This resulted in build
failure for pru-unknown-elf:

  .../gcc/gcc/config/pru/pru.h:576:48: error: cannot convert ‘poly_int<1, long int>’ to ‘int’ in assignment
    576 |         ((VALUE) = GET_MODE_BITSIZE (MODE) - 1 - 32, 2)

Fix by using GET_MODE_UNIT_BITSIZE, the same way the original patch did
for other targets.

Pushed to trunk as r17-5062-g6ae2ad3169ab88.

gcc/ChangeLog:

	* config/pru/pru.h (CLZ_DEFINED_VALUE_AT_ZERO): Use
	GET_MODE_UNIT_BITSIZE.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
---
 gcc/config/pru/pru.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jeff Law Oct. 11, 2026, 4:57 p.m. UTC | #1
On 10/11/26 10:54 AM, Dimitar Dimitrov wrote:
> Commit r17-5047-gd2e1b1248a17d0 started passing the vector mode instead
> of scalar mode to CLZ_DEFINED_VALUE_AT_ZERO.  This resulted in build
> failure for pru-unknown-elf:
>
>    .../gcc/gcc/config/pru/pru.h:576:48: error: cannot convert ‘poly_int<1, long int>’ to ‘int’ in assignment
>      576 |         ((VALUE) = GET_MODE_BITSIZE (MODE) - 1 - 32, 2)
>
> Fix by using GET_MODE_UNIT_BITSIZE, the same way the original patch did
> for other targets.
>
> Pushed to trunk as r17-5062-g6ae2ad3169ab88.
>
> gcc/ChangeLog:
>
> 	* config/pru/pru.h (CLZ_DEFINED_VALUE_AT_ZERO): Use
> 	GET_MODE_UNIT_BITSIZE.
>
> Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
Thanks, I saw pru-elf fail overnight, but I'm still catching up from all 
the travel the last few months, so didn't start to chase it down.  I 
suspect the same problem is also affecting vax.  I'll try your change 
over there too.

Thanks again,
jeff
  
Stefan Schulze Frielinghaus Oct. 12, 2026, 7:30 a.m. UTC | #2
On Sun, Oct 11, 2026 at 10:57:30AM -0600, Jeff Law wrote:
> 
> 
> On 10/11/26 10:54 AM, Dimitar Dimitrov wrote:
> > Commit r17-5047-gd2e1b1248a17d0 started passing the vector mode instead
> > of scalar mode to CLZ_DEFINED_VALUE_AT_ZERO.  This resulted in build
> > failure for pru-unknown-elf:
> > 
> >    .../gcc/gcc/config/pru/pru.h:576:48: error: cannot convert ‘poly_int<1, long int>’ to ‘int’ in assignment
> >      576 |         ((VALUE) = GET_MODE_BITSIZE (MODE) - 1 - 32, 2)
> > 
> > Fix by using GET_MODE_UNIT_BITSIZE, the same way the original patch did
> > for other targets.
> > 
> > Pushed to trunk as r17-5062-g6ae2ad3169ab88.
> > 
> > gcc/ChangeLog:
> > 
> > 	* config/pru/pru.h (CLZ_DEFINED_VALUE_AT_ZERO): Use
> > 	GET_MODE_UNIT_BITSIZE.
> > 
> > Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
> Thanks, I saw pru-elf fail overnight, but I'm still catching up from all the
> travel the last few months, so didn't start to chase it down.  I suspect the
> same problem is also affecting vax.  I'll try your change over there too.

Ups, my bad, in
https://gcc.gnu.org/pipermail/gcc-patches/2026-September/732870.html
I convinced myself that the change is not needed for {nvptx,pru,vax}
since I assumed that the vectorizer does not fire for those.

Since pru and vax are fixed in the meantime (thanks!) this leaves me
with nvptx for which I will prepare a patch shortly.

Sorry for the noise.

Cheers,
Stefan

> 
> Thanks again,
> jeff
  

Patch

diff --git a/gcc/config/pru/pru.h b/gcc/config/pru/pru.h
index a370d08c385..c36b8cfd257 100644
--- a/gcc/config/pru/pru.h
+++ b/gcc/config/pru/pru.h
@@ -573,7 +573,7 @@  do {									\
 
 /* See definition of clz pattern for rationale of the value.  */
 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)	\
-	((VALUE) = GET_MODE_BITSIZE (MODE) - 1 - 32, 2)
+	((VALUE) = GET_MODE_UNIT_BITSIZE (MODE) - 1 - 32, 2)
 
 /* Jumps are cheap on PRU.  */
 #define LOGICAL_OP_NON_SHORT_CIRCUIT		0