* [PATCH] LoongArch: Guard REGNO with REG_P in loongarch_expand_conditional_move [PR115169]
@ 2024-05-22 11:24 Xi Ruoyao
2024-05-23 6:05 ` Lulu Cheng
0 siblings, 1 reply; 2+ messages in thread
From: Xi Ruoyao @ 2024-05-22 11:24 UTC (permalink / raw)
To: gcc-patches; +Cc: chenglulu, i, xuchenghua, Xi Ruoyao
gcc/ChangeLog:
PR target/115169
* config/loongarch/loongarch.cc
(loongarch_expand_conditional_move): Guard REGNO with REG_P.
---
Bootstrapped with --enable-checking=all. Ok for trunk and 14?
gcc/config/loongarch/loongarch.cc | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index e7835ae34ae..1b6df6a4365 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -5344,6 +5344,7 @@ loongarch_expand_conditional_move (rtx *operands)
rtx op1_extend = op1;
/* Record whether operands[2] and operands[3] modes are promoted to word_mode. */
+ bool promote_op[2] = {false, false};
bool promote_p = false;
machine_mode mode = GET_MODE (operands[0]);
@@ -5351,9 +5352,15 @@ loongarch_expand_conditional_move (rtx *operands)
loongarch_emit_float_compare (&code, &op0, &op1);
else
{
- if ((REGNO (op0) == REGNO (operands[2])
- || (REGNO (op1) == REGNO (operands[3]) && (op1 != const0_rtx)))
- && (GET_MODE_SIZE (GET_MODE (op0)) < word_mode))
+ if (GET_MODE_SIZE (GET_MODE (op0)) < word_mode)
+ {
+ promote_op[0] = (REG_P (op0) && REG_P (operands[2]) &&
+ REGNO (op0) == REGNO (operands[2]));
+ promote_op[1] = (REG_P (op1) && REG_P (operands[3]) &&
+ REGNO (op1) == REGNO (operands[3]));
+ }
+
+ if (promote_op[0] || promote_op[1])
{
mode = word_mode;
promote_p = true;
@@ -5395,7 +5402,7 @@ loongarch_expand_conditional_move (rtx *operands)
if (promote_p)
{
- if (REGNO (XEXP (operands[1], 0)) == REGNO (operands[2]))
+ if (promote_op[0])
op2 = op0_extend;
else
{
@@ -5403,7 +5410,7 @@ loongarch_expand_conditional_move (rtx *operands)
op2 = force_reg (mode, op2);
}
- if (REGNO (XEXP (operands[1], 1)) == REGNO (operands[3]))
+ if (promote_op[1])
op3 = op1_extend;
else
{
--
2.45.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] LoongArch: Guard REGNO with REG_P in loongarch_expand_conditional_move [PR115169]
2024-05-22 11:24 [PATCH] LoongArch: Guard REGNO with REG_P in loongarch_expand_conditional_move [PR115169] Xi Ruoyao
@ 2024-05-23 6:05 ` Lulu Cheng
0 siblings, 0 replies; 2+ messages in thread
From: Lulu Cheng @ 2024-05-23 6:05 UTC (permalink / raw)
To: Xi Ruoyao, gcc-patches; +Cc: i, xuchenghua
LGTM!
Thanks!
在 2024/5/22 下午7:24, Xi Ruoyao 写道:
> gcc/ChangeLog:
>
> PR target/115169
> * config/loongarch/loongarch.cc
> (loongarch_expand_conditional_move): Guard REGNO with REG_P.
> ---
>
> Bootstrapped with --enable-checking=all. Ok for trunk and 14?
>
> gcc/config/loongarch/loongarch.cc | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index e7835ae34ae..1b6df6a4365 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -5344,6 +5344,7 @@ loongarch_expand_conditional_move (rtx *operands)
> rtx op1_extend = op1;
>
> /* Record whether operands[2] and operands[3] modes are promoted to word_mode. */
> + bool promote_op[2] = {false, false};
> bool promote_p = false;
> machine_mode mode = GET_MODE (operands[0]);
>
> @@ -5351,9 +5352,15 @@ loongarch_expand_conditional_move (rtx *operands)
> loongarch_emit_float_compare (&code, &op0, &op1);
> else
> {
> - if ((REGNO (op0) == REGNO (operands[2])
> - || (REGNO (op1) == REGNO (operands[3]) && (op1 != const0_rtx)))
> - && (GET_MODE_SIZE (GET_MODE (op0)) < word_mode))
> + if (GET_MODE_SIZE (GET_MODE (op0)) < word_mode)
> + {
> + promote_op[0] = (REG_P (op0) && REG_P (operands[2]) &&
> + REGNO (op0) == REGNO (operands[2]));
> + promote_op[1] = (REG_P (op1) && REG_P (operands[3]) &&
> + REGNO (op1) == REGNO (operands[3]));
> + }
> +
> + if (promote_op[0] || promote_op[1])
> {
> mode = word_mode;
> promote_p = true;
> @@ -5395,7 +5402,7 @@ loongarch_expand_conditional_move (rtx *operands)
>
> if (promote_p)
> {
> - if (REGNO (XEXP (operands[1], 0)) == REGNO (operands[2]))
> + if (promote_op[0])
> op2 = op0_extend;
> else
> {
> @@ -5403,7 +5410,7 @@ loongarch_expand_conditional_move (rtx *operands)
> op2 = force_reg (mode, op2);
> }
>
> - if (REGNO (XEXP (operands[1], 1)) == REGNO (operands[3]))
> + if (promote_op[1])
> op3 = op1_extend;
> else
> {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-23 6:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-22 11:24 [PATCH] LoongArch: Guard REGNO with REG_P in loongarch_expand_conditional_move [PR115169] Xi Ruoyao
2024-05-23 6:05 ` Lulu Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).