working fold_op_cmp implementation

This commit is contained in:
Wolfgang Bumiller 2013-11-12 16:15:02 +01:00
parent 1d5229ee8c
commit eb4486a7ac

9
fold.c
View file

@ -606,11 +606,10 @@ 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) { 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 (fold_can_2(a, b)) {
return fold_constgen_float( if (isfloat(a) && isfloat(b))
fold, return fold_constgen_float(fold, ne != (fold_immvalue_float(a) == fold_immvalue_float(b)));
(ne) ? (fold_immvalue_float(a) != fold_immvalue_float(b)) if (isvector(a) && isvector(b))
: (fold_immvalue_float(a) == fold_immvalue_float(b)) return fold_constgen_float(fold, ne != vec3_cmp(fold_immvalue_vector(a), fold_immvalue_vector(b)));
);
} }
return NULL; return NULL;
} }