@@ -0,0 +1,14 @@
+/* PR tree-optimization/71994 */
+/* { dg-do compile } */
+int om, h6;
+
+void eo (void)
+{
+ const int tl = 1;
+ int ln;
+
+ h6 = (om + tl) > 0;
+ ln = om && (om & h6);
+ h6 = om;
+ om = ln < h6;
+}
@@ -3635,8 +3635,15 @@ maybe_optimize_range_tests (gimple *stmt)
{
gcc_assert (bb == last_bb);
new_op = ops[bbinfo[idx].first_idx++]->op;
+ if (!types_compatible_p (TREE_TYPE (new_op),
+ TREE_TYPE (bbinfo[idx].op))
+ && TREE_CODE (new_op) == INTEGER_CST)
+ new_op = fold_convert (TREE_TYPE (bbinfo[idx].op),
+ new_op);
}
- if (bbinfo[idx].op != new_op)
+ if (bbinfo[idx].op != new_op
+ && types_compatible_p (TREE_TYPE (new_op),
+ TREE_TYPE (bbinfo[idx].op)))
{
imm_use_iterator iter;
use_operand_p use_p;