Commit c2202b70 authored by yb9976's avatar yb9976
Browse files

Prevent optimization if compare relation is trivial.

This fixes opt/fehler302.c.
parent 3c5129c4
......@@ -5398,11 +5398,12 @@ cmp_x_eq_0:
/* for integer modes, we have more */
if (mode_is_int(mode) && !is_Const(left)) {
if (!is_relation(ir_relation_false, relation, possible) &&
!is_relation(ir_relation_true, relation, possible)) {
if ((relation == ir_relation_less || relation == ir_relation_greater_equal) &&
tarval_cmp(tv, get_mode_null(mode)) == ir_relation_greater) {
bitinfo const *const bl = get_bitinfo(left);
if (bl && !is_relation(ir_relation_false, relation, possible)
&& !is_relation(ir_relation_true, relation, possible)) {
if (bl) {
ir_tarval *const uneq = tarval_or(tarval_andnot(tv, bl->z), tarval_andnot(bl->o, tv));
int const hi = get_tarval_highest_bit(uneq);
if (hi >= 0) {
......@@ -5427,8 +5428,7 @@ cmp_x_eq_0:
} else if ((relation == ir_relation_greater || relation == ir_relation_less_equal) &&
tarval_cmp(tv, get_mode_null(mode)) == ir_relation_less) {
bitinfo const *const bl = get_bitinfo(left);
if (bl && !is_relation(ir_relation_false, relation, possible)
&& !is_relation(ir_relation_true, relation, possible)) {
if (bl) {
ir_tarval *const uneq = tarval_or(tarval_andnot(tv, bl->z), tarval_andnot(bl->o, tv));
int const hi = get_tarval_highest_bit(uneq);
if (hi >= 0) {
......@@ -5457,6 +5457,7 @@ reduced_tv:
changedc = true;
DBG_OPT_ALGSIM0(n, n, FS_OPT_CMP_CNST_MAGN);
}
}
/* the following reassociations work only for == and != */
if (rel_eq != ir_relation_false) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment