From: Dale Weiler Date: Sat, 23 Nov 2013 16:14:42 +0000 (-0500) Subject: Fixed pow X-Git-Tag: xonotic-v0.8.0~67 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1c33bcfceb47882912afe485c8cc038f5905b7aa;p=xonotic%2Fgmqcc.git Fixed pow --- diff --git a/intrin.c b/intrin.c index 3fa0d70..e94d475 100644 --- a/intrin.c +++ b/intrin.c @@ -90,6 +90,8 @@ static ast_expression *intrin_pow(intrin_t *intrin) { * float accumulate; * * if (exp == 0.0) + * return 1; + * if (exp == 1.0) * return base; * if (exp < 0) * return 1.0 / pow(base, -exp); @@ -166,7 +168,7 @@ static ast_expression *intrin_pow(intrin_t *intrin) { /* * if (exp == 0.0) - * return base; + * return 1; */ vec_push(body->exprs, (ast_expression*)ast_ifthen_new( @@ -177,6 +179,27 @@ static ast_expression *intrin_pow(intrin_t *intrin) { (ast_expression*)exp, (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( intrin_ctx(intrin), (ast_expression*)base