mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-19 14:50:48 +00:00
Fixed pow
This commit is contained in:
parent
db182819ae
commit
1c33bcfceb
1 changed files with 24 additions and 1 deletions
25
intrin.c
25
intrin.c
|
@ -90,6 +90,8 @@ static ast_expression *intrin_pow(intrin_t *intrin) {
|
||||||
* float accumulate;
|
* float accumulate;
|
||||||
*
|
*
|
||||||
* if (exp == 0.0)
|
* if (exp == 0.0)
|
||||||
|
* return 1;
|
||||||
|
* if (exp == 1.0)
|
||||||
* return base;
|
* return base;
|
||||||
* if (exp < 0)
|
* if (exp < 0)
|
||||||
* return 1.0 / pow(base, -exp);
|
* return 1.0 / pow(base, -exp);
|
||||||
|
@ -166,7 +168,7 @@ static ast_expression *intrin_pow(intrin_t *intrin) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if (exp == 0.0)
|
* if (exp == 0.0)
|
||||||
* return base;
|
* return 1;
|
||||||
*/
|
*/
|
||||||
vec_push(body->exprs,
|
vec_push(body->exprs,
|
||||||
(ast_expression*)ast_ifthen_new(
|
(ast_expression*)ast_ifthen_new(
|
||||||
|
@ -177,6 +179,27 @@ static ast_expression *intrin_pow(intrin_t *intrin) {
|
||||||
(ast_expression*)exp,
|
(ast_expression*)exp,
|
||||||
(ast_expression*)intrin->fold->imm_float[0]
|
(ast_expression*)intrin->fold->imm_float[0]
|
||||||
),
|
),
|
||||||
|
(ast_expression*)ast_return_new(
|
||||||
|
intrin_ctx(intrin),
|
||||||
|
(ast_expression*)intrin->fold->imm_float[1]
|
||||||
|
),
|
||||||
|
NULL
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if (exp == 1.0)
|
||||||
|
* return base;
|
||||||
|
*/
|
||||||
|
vec_push(body->exprs,
|
||||||
|
(ast_expression*)ast_ifthen_new(
|
||||||
|
intrin_ctx(intrin),
|
||||||
|
(ast_expression*)ast_binary_new(
|
||||||
|
intrin_ctx(intrin),
|
||||||
|
INSTR_EQ_F,
|
||||||
|
(ast_expression*)exp,
|
||||||
|
(ast_expression*)intrin->fold->imm_float[1]
|
||||||
|
),
|
||||||
(ast_expression*)ast_return_new(
|
(ast_expression*)ast_return_new(
|
||||||
intrin_ctx(intrin),
|
intrin_ctx(intrin),
|
||||||
(ast_expression*)base
|
(ast_expression*)base
|
||||||
|
|
Loading…
Reference in a new issue