Fix fold_op_cmp

This commit is contained in:
Dale Weiler 2013-11-29 13:48:03 -05:00
parent ac7e1a557d
commit 43e9885a08

13
fold.c
View file

@ -606,10 +606,15 @@ static GMQCC_INLINE ast_expression *fold_op_lteqgt(fold_t *fold, ast_value *a, a
static GMQCC_INLINE ast_expression *fold_op_cmp(fold_t *fold, ast_value *a, ast_value *b, bool ne) {
if (fold_can_2(a, b)) {
if (isfloat(a) && isfloat(b))
return fold_constgen_float(fold, ne != (fold_immvalue_float(a) == fold_immvalue_float(b)));
if (isvector(a) && isvector(b))
return fold_constgen_float(fold, ne != vec3_cmp(fold_immvalue_vector(a), fold_immvalue_vector(b)));
if (isfloat(a) && isfloat(b)) {
float la = fold_immvalue_float(a);
float lb = fold_immvalue_float(b);
return (ast_expression*)fold->imm_float[!!(ne ? la != lb : la == lb)];
} if (isvector(a) && isvector(b)) {
vec3_t la = fold_immvalue_vector(a);
vec3_t lb = fold_immvalue_vector(b);
return (ast_expression*)fold->imm_float[!!(ne ? vec3_cmp(la, lb) : !vec3_cmp(la, lb))];
}
}
return NULL;
}