Fix pow() optimization inconsistencies.
This commit is contained in:
@@ -2138,8 +2138,8 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| jmp ->fff_resfp
|
||||
|.endmacro
|
||||
|
|
||||
|.macro math_extern2, func
|
||||
| .ffunc_nnsse math_ .. func
|
||||
|.macro math_extern2, name, func
|
||||
| .ffunc_nnsse math_ .. name
|
||||
|.if not X64
|
||||
| movsd FPARG1, xmm0
|
||||
| movsd FPARG3, xmm1
|
||||
@@ -2149,6 +2149,9 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| mov BASE, RB
|
||||
| jmp ->fff_resfp
|
||||
|.endmacro
|
||||
|.macro math_extern2, func
|
||||
| math_extern2 func, func
|
||||
|.endmacro
|
||||
|
|
||||
| math_extern log10
|
||||
| math_extern exp
|
||||
@@ -2161,7 +2164,7 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| math_extern sinh
|
||||
| math_extern cosh
|
||||
| math_extern tanh
|
||||
| math_extern2 pow
|
||||
| math_extern2 pow, lj_vm_pow
|
||||
| math_extern2 atan2
|
||||
| math_extern2 fmod
|
||||
|
|
||||
@@ -3038,41 +3041,6 @@ static void build_subroutines(BuildCtx *ctx)
|
||||
| subsd xmm0, xmm1
|
||||
| ret
|
||||
|
|
||||
|// Args in xmm0/eax. Ret in xmm0. xmm0-xmm1 and eax modified.
|
||||
|->vm_powi_sse:
|
||||
| cmp eax, 1; jle >6 // i<=1?
|
||||
| // Now 1 < (unsigned)i <= 0x80000000.
|
||||
|1: // Handle leading zeros.
|
||||
| test eax, 1; jnz >2
|
||||
| mulsd xmm0, xmm0
|
||||
| shr eax, 1
|
||||
| jmp <1
|
||||
|2:
|
||||
| shr eax, 1; jz >5
|
||||
| movaps xmm1, xmm0
|
||||
|3: // Handle trailing bits.
|
||||
| mulsd xmm0, xmm0
|
||||
| shr eax, 1; jz >4
|
||||
| jnc <3
|
||||
| mulsd xmm1, xmm0
|
||||
| jmp <3
|
||||
|4:
|
||||
| mulsd xmm0, xmm1
|
||||
|5:
|
||||
| ret
|
||||
|6:
|
||||
| je <5 // x^1 ==> x
|
||||
| jb >7 // x^0 ==> 1
|
||||
| neg eax
|
||||
| call <1
|
||||
| sseconst_1 xmm1, RDa
|
||||
| divsd xmm1, xmm0
|
||||
| movaps xmm0, xmm1
|
||||
| ret
|
||||
|7:
|
||||
| sseconst_1 xmm0, RDa
|
||||
| ret
|
||||
|
|
||||
|//-----------------------------------------------------------------------
|
||||
|//-- Miscellaneous functions --------------------------------------------
|
||||
|//-----------------------------------------------------------------------
|
||||
@@ -3954,7 +3922,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
|
||||
| movsd FPARG1, xmm0
|
||||
| movsd FPARG3, xmm1
|
||||
|.endif
|
||||
| call extern pow
|
||||
| call extern lj_vm_pow
|
||||
| movzx RA, PC_RA
|
||||
| mov BASE, RB
|
||||
|.if X64
|
||||
|
||||
Reference in New Issue
Block a user