Fix folding logic for conditions.

This commit is contained in:
Dale Weiler 2013-08-29 00:18:48 -04:00
parent a7c1f6f021
commit 51ef277e21

2
fold.c
View file

@ -765,7 +765,7 @@ int fold_cond(ir_value *condval, ast_function *func, ast_ifthen *branch) {
ast_expression_codegen *cgen;
ir_block *elide;
ir_value *dummy;
bool istrue = (fold_immvalue_float(condval) == 1.0f && branch->on_true);
bool istrue = (fold_immvalue_float(condval) != 0.0f && branch->on_true);
bool isfalse = (fold_immvalue_float(condval) == 0.0f && branch->on_false);
ast_expression *path = (istrue) ? branch->on_true :
(isfalse) ? branch->on_false : NULL;