* tree-vrp.c (compare_range_with_value): Return true or false
for ~[VAL_1, VAL_2] OP VAL if VAL_1 <= VAL <= VAL_2 for NE_EXPR and
EQ_EXPR respectively.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102558
138bc75d-0d04-0410-961f-
82ee72b054a4
+2005-07-29 James A. Morrison <phython@gcc.gnu.org>
+
+ * tree-vrp.c (compare_range_with_value): Return true or false
+ for ~[VAL_1, VAL_2] OP VAL if VAL_1 <= VAL <= VAL_2 for NE_EXPR and
+ EQ_EXPR respectively.
+
2005-07-29 Kazu Hirata <kazu@codesourcery.com>
* cfg.c, tree-complex.c, config/frv/frv.c, config/i386/i386.c:
+2005-07-29 James A. Morrison <phython@gcc.gnu.org>
+
+ * gcc.dg/tree-ssa/vrp19.c: New test.
+ * gcc.dg/tree-ssa-vrp20.c: New test.
+
2005-07-29 Joseph S. Myers <joseph@codesourcery.com>
PR c/22240
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fwrapv -O1 -ftree-vrp -fdump-tree-vrp" } */
+
+#include <limits.h>
+extern void abort ();
+extern void exit (int);
+
+int f (int a) {
+ if (a != INT_MIN) {
+ a = a > 0 ? a : -a;
+ if (a < 0)
+ return 1;
+ }
+ return 0;
+}
+
+int g (int b) {
+ if (b != INT_MIN) {
+ b = b > 0 ? b : -b;
+ if (b >= 0)
+ return 0;
+ }
+ return 1;
+}
+/* { dg-final { scan-tree-dump "Folding predicate a_. < 0 to 0" "vrp" } } */
+/* { dg-final { scan-tree-dump "Folding predicate b_. >= 0 to 1" "vrp" } } */
+/* { dg-final { cleanup-tree-dump "vrp" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fwrapv -O1 -ftree-vrp -fdump-tree-vrp" } */
+
+extern void abort ();
+extern void exit (int);
+
+int f (int a) {
+ if (a != 0) {
+ a = a > 0 ? a : -a;
+ if (a == 0)
+ return 1;
+ return 0;
+ }
+ return 0;
+}
+
+int g (int b) {
+ if (b != 0) {
+ b = b > 0 ? b : -b;
+ if (b != 0)
+ return 0;
+ }
+ return 1;
+}
+
+/* { dg-final { scan-tree-dump "Folding predicate a_. == 0 to 0" "vrp" } } */
+/* { dg-final { scan-tree-dump "Folding predicate b_. != 0 to 1" "vrp" } } */
+/* { dg-final { cleanup-tree-dump "vrp" } } */
|| comp == LE_EXPR)
return NULL_TREE;
- /* ~[VAL, VAL] == VAL is always false. */
- if (compare_values (vr->min, val) == 0
- && compare_values (vr->max, val) == 0)
+ /* ~[VAL_1, VAL_2] OP VAL is known if VAL_1 <= VAL <= VAL_2. */
+ if (value_inside_range (val, vr) == 1)
return (comp == NE_EXPR) ? boolean_true_node : boolean_false_node;
return NULL_TREE;