[PULL 29/29] tcg: Fix constant propagation in tcg_reg_alloc_dup

Richard Henderson posted 29 patches 4 months, 2 weeks ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <Alistair.Francis@wdc.com>
There is a newer version of this series
[PULL 29/29] tcg: Fix constant propagation in tcg_reg_alloc_dup
Posted by Richard Henderson 4 months, 2 weeks ago
The scalar constant must be replicated for dup.

Cc: qemu-stable@nongnu.org
Fixes: bab1671f0fa ("tcg: Manually expand INDEX_op_dup_vec")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3002
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/tcg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tcg/tcg.c b/tcg/tcg.c
index d714ae2889..50d40b9cbe 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -5154,7 +5154,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op)
 
     if (its->val_type == TEMP_VAL_CONST) {
         /* Propagate constant via movi -> dupi.  */
-        tcg_target_ulong val = its->val;
+        tcg_target_ulong val = dup_const(vece, its->val);
         if (IS_DEAD_ARG(1)) {
             temp_dead(s, its);
         }
-- 
2.43.0
Re: [PULL 29/29] tcg: Fix constant propagation in tcg_reg_alloc_dup
Posted by Michael Tokarev 4 months, 2 weeks ago
On 30.06.2025 18:28, Richard Henderson wrote:
> The scalar constant must be replicated for dup.
> 
> Cc: qemu-stable@nongnu.org
> Fixes: bab1671f0fa ("tcg: Manually expand INDEX_op_dup_vec")
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3002
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/tcg.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index d714ae2889..50d40b9cbe 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -5154,7 +5154,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op)
>   
>       if (its->val_type == TEMP_VAL_CONST) {
>           /* Propagate constant via movi -> dupi.  */
> -        tcg_target_ulong val = its->val;
> +        tcg_target_ulong val = dup_const(vece, its->val);
>           if (IS_DEAD_ARG(1)) {
>               temp_dead(s, its);
>           }

Hi Richard!

Does this apply to 7.2.x series, where temps had to be freed
explicitly?

Thanks,

/mjt
Re: [PULL 29/29] tcg: Fix constant propagation in tcg_reg_alloc_dup
Posted by Richard Henderson 4 months, 2 weeks ago
On 7/1/25 13:04, Michael Tokarev wrote:
> On 30.06.2025 18:28, Richard Henderson wrote:
>> The scalar constant must be replicated for dup.
>>
>> Cc: qemu-stable@nongnu.org
>> Fixes: bab1671f0fa ("tcg: Manually expand INDEX_op_dup_vec")
>> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3002
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   tcg/tcg.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tcg/tcg.c b/tcg/tcg.c
>> index d714ae2889..50d40b9cbe 100644
>> --- a/tcg/tcg.c
>> +++ b/tcg/tcg.c
>> @@ -5154,7 +5154,7 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp *op)
>>       if (its->val_type == TEMP_VAL_CONST) {
>>           /* Propagate constant via movi -> dupi.  */
>> -        tcg_target_ulong val = its->val;
>> +        tcg_target_ulong val = dup_const(vece, its->val);
>>           if (IS_DEAD_ARG(1)) {
>>               temp_dead(s, its);
>>           }
> 
> Hi Richard!
> 
> Does this apply to 7.2.x series, where temps had to be freed
> explicitly?

Yep.

r~