diff mbox series

LoongArch: Fix mode size comparision in loongarch_expand_conditional_move

Message ID 20240612030705.20797-1-xry111@xry111.site
State New
Headers show
Series LoongArch: Fix mode size comparision in loongarch_expand_conditional_move | expand

Commit Message

Xi Ruoyao June 12, 2024, 3:06 a.m. UTC
We were comparing a mode size with word_mode, but word_mode is an enum
value thus this does not really make any sense.  (Un)luckily E_DImode
happens to be 8 so this seemed to work, but let's make it correct so it
won't blow up when we add LA32 support or add another machine mode...

gcc/ChangeLog:

	* config/loongarch/loongarch.cc
	(loongarch_expand_conditional_move): Compare mode size with
	UNITS_PER_WORD instead of word_mode.
---

I've not fully tested this but it should be obvious.  Ok for trunk?

 gcc/config/loongarch/loongarch.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Lulu Cheng June 12, 2024, 6:26 a.m. UTC | #1
在 2024/6/12 上午11:06, Xi Ruoyao 写道:
> We were comparing a mode size with word_mode, but word_mode is an enum
> value thus this does not really make any sense.  (Un)luckily E_DImode
> happens to be 8 so this seemed to work, but let's make it correct so it
> won't blow up when we add LA32 support or add another machine mode...
>
> gcc/ChangeLog:
>
> 	* config/loongarch/loongarch.cc
> 	(loongarch_expand_conditional_move): Compare mode size with
> 	UNITS_PER_WORD instead of word_mode.
> ---
>
> I've not fully tested this but it should be obvious.  Ok for trunk?
>
>   gcc/config/loongarch/loongarch.cc | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index eb132f06c2e..bc3dd2b713e 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -5371,7 +5371,7 @@ loongarch_expand_conditional_move (rtx *operands)
>       loongarch_emit_float_compare (&code, &op0, &op1);
>     else
>       {
> -      if (GET_MODE_SIZE (GET_MODE (op0)) < word_mode)
> +      if (GET_MODE_SIZE (GET_MODE (op0)) < UNITS_PER_WORD)
>   	{
>   	  promote_op[0] = (REG_P (op0) && REG_P (operands[2]) &&
>   			   REGNO (op0) == REGNO (operands[2]));

This is indeed a bug and I don't think there is a problem with this change.

Thanks!
diff mbox series

Patch

diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index eb132f06c2e..bc3dd2b713e 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -5371,7 +5371,7 @@  loongarch_expand_conditional_move (rtx *operands)
     loongarch_emit_float_compare (&code, &op0, &op1);
   else
     {
-      if (GET_MODE_SIZE (GET_MODE (op0)) < word_mode)
+      if (GET_MODE_SIZE (GET_MODE (op0)) < UNITS_PER_WORD)
 	{
 	  promote_op[0] = (REG_P (op0) && REG_P (operands[2]) &&
 			   REGNO (op0) == REGNO (operands[2]));