fix 0-x being turned into x

This commit is contained in:
Wolfgang Bumiller 2013-11-06 16:57:04 +01:00
parent 99de3cf4f5
commit de14d514f3

8
fold.c
View file

@ -799,8 +799,10 @@ static ast_expression *fold_superfluous(ast_expression *left, ast_expression *ri
break; break;
case INSTR_ADD_F:
case INSTR_SUB_F: case INSTR_SUB_F:
if (swapped)
return NULL;
case INSTR_ADD_F:
if (fold_immvalue_float(load) == 0.0f) { if (fold_immvalue_float(load) == 0.0f) {
++opts_optimizationcount[OPTIM_PEEPHOLE]; ++opts_optimizationcount[OPTIM_PEEPHOLE];
ast_unref(right); ast_unref(right);
@ -816,8 +818,10 @@ static ast_expression *fold_superfluous(ast_expression *left, ast_expression *ri
} }
break; break;
case INSTR_ADD_V:
case INSTR_SUB_V: case INSTR_SUB_V:
if (swapped)
return NULL;
case INSTR_ADD_V:
if (vec3_cmp(fold_immvalue_vector(load), vec3_create(0, 0, 0))) { if (vec3_cmp(fold_immvalue_vector(load), vec3_create(0, 0, 0))) {
++opts_optimizationcount[OPTIM_PEEPHOLE]; ++opts_optimizationcount[OPTIM_PEEPHOLE];
ast_unref(right); ast_unref(right);