@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+extern void abort (void);
+
+int
+foo (int k, int j)
+{
+ if (j >= 10)
+ {
+ if (j < k)
+ {
+ k++;
+ if (k < 10)
+ abort ();
+ }
+ }
+
+ return j;
+}
+/* { dg-final { scan-tree-dump "\\\[12, \\+INF" "evrp" } } */
@@ -8553,11 +8553,26 @@ intersect_ranges (enum value_range_type *vr0type,
gcc_unreachable ();
}
+ /* If one is a complex value range involving SSA_NAME
+ and other is INTEGER_CST, prefer INTEGER_CST. */
+ else if (vr1type == VR_RANGE
+ && INTEGER_CST == TREE_CODE (vr1min)
+ && INTEGER_CST == TREE_CODE (vr1max)
+ && (((INTEGER_CST != TREE_CODE (*vr0min)
+ && SSA_NAME != TREE_CODE (*vr0min))
+ || ((INTEGER_CST != TREE_CODE (*vr0max)
+ && SSA_NAME != TREE_CODE (*vr0max))))))
+ {
+ *vr0type = vr1type;
+ *vr0min = vr1min;
+ *vr0max = vr1max;
+ }
+
/* As a fallback simply use { *VRTYPE, *VR0MIN, *VR0MAX } as
result for the intersection. That's always a conservative
correct estimate unless VR1 is a constant singleton range
in which case we choose that. */
- if (vr1type == VR_RANGE
+ else if (vr1type == VR_RANGE
&& is_gimple_min_invariant (vr1min)
&& vrp_operand_equal_p (vr1min, vr1max))
{