Skip to content

Commit

Permalink
gas64: handle #inf and NaN in float comparisons (SARG)
Browse files Browse the repository at this point in the history
- previously some #inf handling was incorrect
- this change should give same results as gcc 64-bit
  • Loading branch information
jayrm committed Jun 22, 2023
1 parent 9e2ffed commit 097ed6a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
3 changes: 2 additions & 1 deletion changelog.txt
Expand Up @@ -6,7 +6,8 @@ Version 1.10.1

[fixed]
- sf.net #982: Array descriptors emitted incorrectly in gcc backend
- gas64: emit debug information statics
- gas64: emit debug information for statics
- gas64: handle #inf's and NaN's in float comparisons


Version 1.10.0
Expand Down
56 changes: 38 additions & 18 deletions src/compiler/ir-gas64.bas
Expand Up @@ -3196,32 +3196,52 @@ private sub bop_float( _
asm_code("mov "+*regstrq(vrreg)+", -1")
end if

asm_code(compreg+"xmm0, xmm1")

if op=AST_OP_EQ then
lname2 = *symbUniqueLabel( )
asm_code("jp "+lname2) ''different true very big (or very small value)
elseif op=AST_OP_NE then
if label=0 then
asm_code("jp "+lname1)
else
asm_code("jp "+*symbGetMangledName( label ))''different true
end if
end if

select case op
case AST_OP_EQ
asm_code(compreg+"xmm0, xmm1")
lname2 = *symbUniqueLabel( )
asm_code("jp "+lname2) ''different true very big (or very small value)
jmpcode=@"je " ''different not true
case AST_OP_NE
asm_code(compreg+"xmm0, xmm1")
if label=0 then
asm_code("jp "+lname1)
else
asm_code("jp "+*symbGetMangledName( label ))''different true
end if
jmpcode=@"jne " ''different true
case AST_OP_LT ''todo optimise xmm1 if memory do directly
jmpcode=@"jb "''above true
case AST_OP_LT
if label<>0 then
asm_code(compreg+"xmm0, xmm1")
jmpcode=@"jb "
else
asm_code(compreg+"xmm1, xmm0")
jmpcode=@"ja "
End If
case AST_OP_LE
jmpcode=@"jbe " ''above or equal true
if label<>0 then
asm_code(compreg+"xmm0, xmm1")
jmpcode=@"jbe "
else
asm_code(compreg+"xmm1, xmm0")
jmpcode=@"jae "
End If
case AST_OP_GT
jmpcode=@"ja "''below true
if label<>0 then
asm_code(compreg+"xmm1, xmm0")
jmpcode=@"jb "
else
asm_code(compreg+"xmm0, xmm1")
jmpcode=@"ja "
End If
case AST_OP_GE
jmpcode=@"jae "''below or equal true
if label<>0 then
asm_code(compreg+"xmm1, xmm0")
jmpcode=@"jbe "
else
asm_code(compreg+"xmm0, xmm1")
jmpcode=@"jae "
End If
end select

if label=0 then
Expand Down

0 comments on commit 097ed6a

Please sign in to comment.