Skip to content

Conversation

@Aqua-Peak
Copy link
Contributor

(1)“-0xfffffff” is seen as “unsigned int”。Here what is need shoule be INT_MIN。“-0x80000000L” is equal to INT_MIN and "L" is important that seen as long。 the exmaple code(I have tested in RV64(Vision Star2)and arm64(Pi5).

#include <stdio.h>
int main(){
  ssize_t a = 0;
  if(a < -0xffffffff)
     printf("-0xfffffff is seen as positive value \n");
  return 0;
}

(2)"0xffffffff". Here what is need shoule be INT_MAX that should be "0x7fffffff"。 (3) the same situation is existed in “la64 GETIP_”.

(1)“-0xfffffff” is seen as “unsigned int”。Here what is need shoule be INT_MIN。“-0x80000000L”  is equal to INT_MIN and "L" is important that seen as long。 
the exmaple code(I have tested in RV64(Vision Star2)and arm64(Pi5).
```c
#include <stdio.h>
int main(){
  ssize_t a = 0;
  if(a < -0xffffffff)
     printf("-0xfffffff is seen as positive value \n");
  return 0;
}
```
(2)"0xffffffff". Here what is need shoule be INT_MAX that should be "0x7fffffff"。
(3) the same situation is existed in “la64 GETIP_”.
@ksco
Copy link
Collaborator

ksco commented Jan 17, 2026

Oh thank you for this, but I think changing 0xffffffff to 0xffffffffL should be enough here.

@Aqua-Peak
Copy link
Contributor Author

        } else if (_delta_ip >= -2048 && _delta_ip < 2048) {      \
            ADDI(xRIP, xRIP, _delta_ip);                          \
        } else if (_delta_ip < 0 && _delta_ip >= -0xffffffff) {   \
            MOV32w(scratch, -_delta_ip);                          \
            SUB(xRIP, xRIP, scratch);                             \
        } else if (_delta_ip > 0 && _delta_ip <= 0xffffffff) {    \
            MOV32w(scratch, _delta_ip);                           \
            ADD(xRIP, xRIP, scratch);                             \
        } else {      

using MOV32w represents that value ranges from INT_MIN to INT_MAX. I thank INT_INT"-80000000L" and INT_MAX 0x7fffffff" may be better.

@ksco
Copy link
Collaborator

ksco commented Jan 17, 2026

No, it's an unsigned 32bit int.

@Aqua-Peak
Copy link
Contributor Author

I see. changing 0xffffffff to 0xffffffffL is Ok.

@ksco
Copy link
Collaborator

ksco commented Jan 17, 2026

Can you change LoongArch counterpart too?

@Aqua-Peak
Copy link
Contributor Author

OK , I have do the work for rv64 and la64.

@ksco ksco changed the title Fix delta_ip range checks in dynarec_rv64_helper.h [RV64_DYNAREC][LA64_DYNAREC] Fix delta_ip range checks Jan 17, 2026
@ksco ksco changed the title [RV64_DYNAREC][LA64_DYNAREC] Fix delta_ip range checks [RV64_DYNAREC] Fix delta_ip range checks ([LA64_DYNAREC] too) Jan 17, 2026
@ksco ksco marked this pull request as ready for review January 17, 2026 07:09
@ksco ksco requested a review from ptitSeb January 17, 2026 15:57
@ptitSeb ptitSeb merged commit c5c52c2 into ptitSeb:main Jan 17, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants