target/loongarch/tcg/insn_trans/trans_vec.c.inc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
According to the specification, [X]VLDI should trigger an invalid instruction
exception only when Bit[12] is 1 and Bit[11:8] > 12. This patch fixes an issue
where an exception was incorrectly raised even when Bit[12] was 0.
Test case:
```
.global main
main:
vldi $vr0, 3328
ret
```
Reported-by: Zhou Qiankang <wszqkzqk@qq.com>
Signed-off-by: WANG Rui <wangrui@loongson.cn>
---
target/loongarch/tcg/insn_trans/trans_vec.c.inc | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/target/loongarch/tcg/insn_trans/trans_vec.c.inc b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
index 78730029cb..ee10a9ebe1 100644
--- a/target/loongarch/tcg/insn_trans/trans_vec.c.inc
+++ b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
@@ -3585,11 +3585,6 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
int sel, vece;
uint64_t value;
- if (!check_valid_vldi_mode(a)) {
- generate_exception(ctx, EXCCODE_INE);
- return true;
- }
-
if (!check_vec(ctx, oprsz)) {
return true;
}
@@ -3597,6 +3592,11 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
sel = (a->imm >> 12) & 0x1;
if (sel) {
+ if (!check_valid_vldi_mode(a)) {
+ generate_exception(ctx, EXCCODE_INE);
+ return true;
+ }
+
value = vldi_get_value(ctx, a->imm);
vece = MO_64;
} else {
--
2.50.1
Hi folks,
On Mon, Aug 4, 2025 at 10:31 AM WANG Rui <wangrui@loongson.cn> wrote:
>
> According to the specification, [X]VLDI should trigger an invalid instruction
> exception only when Bit[12] is 1 and Bit[11:8] > 12. This patch fixes an issue
> where an exception was incorrectly raised even when Bit[12] was 0.
>
> Test case:
>
> ```
> .global main
> main:
> vldi $vr0, 3328
> ret
> ```
>
> Reported-by: Zhou Qiankang <wszqkzqk@qq.com>
> Signed-off-by: WANG Rui <wangrui@loongson.cn>
> ---
> target/loongarch/tcg/insn_trans/trans_vec.c.inc | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/target/loongarch/tcg/insn_trans/trans_vec.c.inc b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
> index 78730029cb..ee10a9ebe1 100644
> --- a/target/loongarch/tcg/insn_trans/trans_vec.c.inc
> +++ b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
> @@ -3585,11 +3585,6 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
> int sel, vece;
> uint64_t value;
>
> - if (!check_valid_vldi_mode(a)) {
> - generate_exception(ctx, EXCCODE_INE);
> - return true;
> - }
Should the INE exception be prioritized over the [A]SXD exception in this case?
- Rui
> -
> if (!check_vec(ctx, oprsz)) {
> return true;
> }
> @@ -3597,6 +3592,11 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
> sel = (a->imm >> 12) & 0x1;
>
> if (sel) {
> + if (!check_valid_vldi_mode(a)) {
> + generate_exception(ctx, EXCCODE_INE);
> + return true;
> + }
> +
> value = vldi_get_value(ctx, a->imm);
> vece = MO_64;
> } else {
> --
> 2.50.1
>
在 2025/8/4 上午11:17, WANG Rui 写道:
> Hi folks,
>
> On Mon, Aug 4, 2025 at 10:31 AM WANG Rui <wangrui@loongson.cn> wrote:
>> According to the specification, [X]VLDI should trigger an invalid instruction
>> exception only when Bit[12] is 1 and Bit[11:8] > 12. This patch fixes an issue
>> where an exception was incorrectly raised even when Bit[12] was 0.
>>
>> Test case:
>>
>> ```
>> .global main
>> main:
>> vldi $vr0, 3328
>> ret
>> ```
>>
>> Reported-by: Zhou Qiankang <wszqkzqk@qq.com>
>> Signed-off-by: WANG Rui <wangrui@loongson.cn>
>> ---
>> target/loongarch/tcg/insn_trans/trans_vec.c.inc | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/target/loongarch/tcg/insn_trans/trans_vec.c.inc b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
>> index 78730029cb..ee10a9ebe1 100644
>> --- a/target/loongarch/tcg/insn_trans/trans_vec.c.inc
>> +++ b/target/loongarch/tcg/insn_trans/trans_vec.c.inc
>> @@ -3585,11 +3585,6 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
>> int sel, vece;
>> uint64_t value;
>>
>> - if (!check_valid_vldi_mode(a)) {
>> - generate_exception(ctx, EXCCODE_INE);
>> - return true;
>> - }
> Should the INE exception be prioritized over the [A]SXD exception in this case?
yes, I think we should. this is like ARM.
As Richiard said 'For Arm, at least, decode errors take precedence over
disabled functional units.'
Thanks.
Song Gao
> - Rui
>
>> -
>> if (!check_vec(ctx, oprsz)) {
>> return true;
>> }
>> @@ -3597,6 +3592,11 @@ static bool gen_vldi(DisasContext *ctx, arg_vldi *a, uint32_t oprsz)
>> sel = (a->imm >> 12) & 0x1;
>>
>> if (sel) {
>> + if (!check_valid_vldi_mode(a)) {
>> + generate_exception(ctx, EXCCODE_INE);
>> + return true;
>> + }
>> +
>> value = vldi_get_value(ctx, a->imm);
>> vece = MO_64;
>> } else {
>> --
>> 2.50.1
>>
© 2016 - 2025 Red Hat, Inc.