diff mbox series

Check SCALAR_INT_MODE_P in try_const_anchors

Message ID 20230616081455.1697928-1-guojiufu@linux.ibm.com
State New
Headers show
Series Check SCALAR_INT_MODE_P in try_const_anchors | expand

Commit Message

Jiufu Guo June 16, 2023, 8:14 a.m. UTC
Hi,

The const_anchor in cse.cc supports integer constants only.
There is a "gcc_assert (SCALAR_INT_MODE_P (mode))" in
try_const_anchors.

In the latest code, some non-integer modes are used with const int.
For examples:
"set (mem/c:BLK (xx) (const_int 0 [0])" occur in md files of
rs6000, i386, arm, and pa. For this, the mode may be BLKmode.
Pattern "(set (strict_low_part (xx)) (const_int xx))" could
be generated in a few ports. For this, the mode may be VOIDmode.

So, avoid mode other than SCALAR_INT_MODE in try_const_anchors
would be needed.

Some discussions in the previous thread:
https://gcc.gnu.org/pipermail/gcc-patches/2023-June/621097.html

Bootstrap &regtest pass on ppc64{,le} and x86_64.
Is this ok for trunk?


BR,
Jeff (Jiufu Guo)

gcc/ChangeLog:

	* cse.cc (try_const_anchors): Check SCALAR_INT_MODE.

---
 gcc/cse.cc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Richard Biener June 16, 2023, 8:46 a.m. UTC | #1
On Fri, 16 Jun 2023, Jiufu Guo wrote:

> Hi,
> 
> The const_anchor in cse.cc supports integer constants only.
> There is a "gcc_assert (SCALAR_INT_MODE_P (mode))" in
> try_const_anchors.
> 
> In the latest code, some non-integer modes are used with const int.
> For examples:
> "set (mem/c:BLK (xx) (const_int 0 [0])" occur in md files of
> rs6000, i386, arm, and pa. For this, the mode may be BLKmode.
> Pattern "(set (strict_low_part (xx)) (const_int xx))" could
> be generated in a few ports. For this, the mode may be VOIDmode.
> 
> So, avoid mode other than SCALAR_INT_MODE in try_const_anchors
> would be needed.
> 
> Some discussions in the previous thread:
> https://gcc.gnu.org/pipermail/gcc-patches/2023-June/621097.html
> 
> Bootstrap &regtest pass on ppc64{,le} and x86_64.
> Is this ok for trunk?

OK.

Richard.

> 
> BR,
> Jeff (Jiufu Guo)
> 
> gcc/ChangeLog:
> 
> 	* cse.cc (try_const_anchors): Check SCALAR_INT_MODE.
> 
> ---
>  gcc/cse.cc | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/gcc/cse.cc b/gcc/cse.cc
> index 2bb63ac4105..ddb76fd281d 100644
> --- a/gcc/cse.cc
> +++ b/gcc/cse.cc
> @@ -1312,11 +1312,10 @@ try_const_anchors (rtx src_const, machine_mode mode)
>    rtx lower_exp = NULL_RTX, upper_exp = NULL_RTX;
>    unsigned lower_old, upper_old;
>  
> -  /* CONST_INT is used for CC modes, but we should leave those alone.  */
> -  if (GET_MODE_CLASS (mode) == MODE_CC)
> +  /* CONST_INT may be in various modes, avoid non-scalar-int mode. */
> +  if (!SCALAR_INT_MODE_P (mode))
>      return NULL_RTX;
>  
> -  gcc_assert (SCALAR_INT_MODE_P (mode));
>    if (!compute_const_anchors (src_const, &lower_base, &lower_offs,
>  			      &upper_base, &upper_offs))
>      return NULL_RTX;
>
Jiufu Guo June 19, 2023, 2:49 a.m. UTC | #2
Hi,

Richard Biener <rguenther@suse.de> writes:

> On Fri, 16 Jun 2023, Jiufu Guo wrote:
>
>> Hi,
>> 
>> The const_anchor in cse.cc supports integer constants only.
>> There is a "gcc_assert (SCALAR_INT_MODE_P (mode))" in
>> try_const_anchors.
>> 
>> In the latest code, some non-integer modes are used with const int.
>> For examples:
>> "set (mem/c:BLK (xx) (const_int 0 [0])" occur in md files of
>> rs6000, i386, arm, and pa. For this, the mode may be BLKmode.
>> Pattern "(set (strict_low_part (xx)) (const_int xx))" could
>> be generated in a few ports. For this, the mode may be VOIDmode.
>> 
>> So, avoid mode other than SCALAR_INT_MODE in try_const_anchors
>> would be needed.
>> 
>> Some discussions in the previous thread:
>> https://gcc.gnu.org/pipermail/gcc-patches/2023-June/621097.html
>> 
>> Bootstrap &regtest pass on ppc64{,le} and x86_64.
>> Is this ok for trunk?
>
> OK.

Thanks a lot! Committed via r14-1918-gc0bd79300e8fad.

BR,
Jeff (Jiufu Guo)

>
> Richard.
>
>> 
>> BR,
>> Jeff (Jiufu Guo)
>> 
>> gcc/ChangeLog:
>> 
>> 	* cse.cc (try_const_anchors): Check SCALAR_INT_MODE.
>> 
>> ---
>>  gcc/cse.cc | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>> 
>> diff --git a/gcc/cse.cc b/gcc/cse.cc
>> index 2bb63ac4105..ddb76fd281d 100644
>> --- a/gcc/cse.cc
>> +++ b/gcc/cse.cc
>> @@ -1312,11 +1312,10 @@ try_const_anchors (rtx src_const, machine_mode mode)
>>    rtx lower_exp = NULL_RTX, upper_exp = NULL_RTX;
>>    unsigned lower_old, upper_old;
>>  
>> -  /* CONST_INT is used for CC modes, but we should leave those alone.  */
>> -  if (GET_MODE_CLASS (mode) == MODE_CC)
>> +  /* CONST_INT may be in various modes, avoid non-scalar-int mode. */
>> +  if (!SCALAR_INT_MODE_P (mode))
>>      return NULL_RTX;
>>  
>> -  gcc_assert (SCALAR_INT_MODE_P (mode));
>>    if (!compute_const_anchors (src_const, &lower_base, &lower_offs,
>>  			      &upper_base, &upper_offs))
>>      return NULL_RTX;
>>
diff mbox series

Patch

diff --git a/gcc/cse.cc b/gcc/cse.cc
index 2bb63ac4105..ddb76fd281d 100644
--- a/gcc/cse.cc
+++ b/gcc/cse.cc
@@ -1312,11 +1312,10 @@  try_const_anchors (rtx src_const, machine_mode mode)
   rtx lower_exp = NULL_RTX, upper_exp = NULL_RTX;
   unsigned lower_old, upper_old;
 
-  /* CONST_INT is used for CC modes, but we should leave those alone.  */
-  if (GET_MODE_CLASS (mode) == MODE_CC)
+  /* CONST_INT may be in various modes, avoid non-scalar-int mode. */
+  if (!SCALAR_INT_MODE_P (mode))
     return NULL_RTX;
 
-  gcc_assert (SCALAR_INT_MODE_P (mode));
   if (!compute_const_anchors (src_const, &lower_base, &lower_offs,
 			      &upper_base, &upper_offs))
     return NULL_RTX;