aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKugan Vivekanandarajah <kuganv@linaro.org>2016-09-27 03:41:14 +0000
committerKugan Vivekanandarajah <kugan@gcc.gnu.org>2016-09-27 03:41:14 +0000
commit3a4228babc083065faaf41568fbc92e0e562a401 (patch)
treef998314ef3804e0b57a614c034f940830e779812
parent963da599303d6abae1507c2b4fea29c941b10289 (diff)
downloadgcc-3a4228babc083065faaf41568fbc92e0e562a401.zip
gcc-3a4228babc083065faaf41568fbc92e0e562a401.tar.gz
gcc-3a4228babc083065faaf41568fbc92e0e562a401.tar.bz2
Fix ipa-vrp convert value_range
gcc/ChangeLog: 2016-09-27 Kugan Vivekanandarajah <kuganv@linaro.org> PR ipa/77677 * ipa-prop.c (ipa_compute_jump_functions_for_edge): Use extract_range_from_unary_expr to convert value_range. * tree-vrp.c (extract_range_from_unary_expr_1): Rename to. (extract_range_from_unary_expr): This. * tree-vrp.h (extract_range_from_unary_expr): Declare. gcc/testsuite/ChangeLog: 2016-09-27 Kugan Vivekanandarajah <kuganv@linaro.org> PR ipa/77677 * gcc.dg/torture/pr77677-2.c: New test. From-SVN: r240517
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/ipa-prop.c22
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr77677-2.c17
-rw-r--r--gcc/tree-vrp.c16
-rw-r--r--gcc/tree-vrp.h5
6 files changed, 60 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 55824e5..3e5b099 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2016-09-27 Kugan Vivekanandarajah <kuganv@linaro.org>
+
+ PR ipa/77677
+ * ipa-prop.c (ipa_compute_jump_functions_for_edge): Use
+ extract_range_from_unary_expr to convert value_range.
+ * tree-vrp.c (extract_range_from_unary_expr_1): Rename to.
+ (extract_range_from_unary_expr): This.
+ * tree-vrp.h (extract_range_from_unary_expr): Declare.
+
2016-09-27 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.md (movcc_internal1): Disparage using CTR or LR.
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index feecd23..302a479 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -1703,13 +1703,23 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
if (TREE_CODE (arg) == SSA_NAME
&& param_type
&& (type = get_range_info (arg, &min, &max))
- && (type == VR_RANGE || type == VR_ANTI_RANGE)
- && (min.get_precision () <= TYPE_PRECISION (param_type)))
+ && (type == VR_RANGE || type == VR_ANTI_RANGE))
{
- jfunc->vr_known = true;
- jfunc->m_vr.type = type;
- jfunc->m_vr.min = wide_int_to_tree (param_type, min);
- jfunc->m_vr.max = wide_int_to_tree (param_type, max);
+ value_range vr;
+
+ vr.type = type;
+ vr.min = wide_int_to_tree (TREE_TYPE (arg), min);
+ vr.max = wide_int_to_tree (TREE_TYPE (arg), max);
+ vr.equiv = NULL;
+ extract_range_from_unary_expr (&jfunc->m_vr,
+ NOP_EXPR,
+ param_type,
+ &vr, TREE_TYPE (arg));
+ if (jfunc->m_vr.type == VR_RANGE
+ || jfunc->m_vr.type == VR_ANTI_RANGE)
+ jfunc->vr_known = true;
+ else
+ jfunc->vr_known = false;
}
else
gcc_assert (!jfunc->vr_known);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 446848f..4b24d64 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-09-27 Kugan Vivekanandarajah <kuganv@linaro.org>
+
+ PR ipa/77677
+ * gcc.dg/torture/pr77677-2.c: New test.
+
2016-09-26 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/77420
diff --git a/gcc/testsuite/gcc.dg/torture/pr77677-2.c b/gcc/testsuite/gcc.dg/torture/pr77677-2.c
new file mode 100644
index 0000000..b586d7a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr77677-2.c
@@ -0,0 +1,17 @@
+/* PR ipa/77677 */
+/* { dg-do compile } */
+/* { dg-options "-w" } */
+
+enum machine_mode { MAX_MACHINE_MODE };
+
+struct {
+ int mode : 8;
+} a;
+int b;
+
+static int fn1();
+
+void fn2() { fn1(a, a.mode); }
+
+int fn1(a, mode) enum machine_mode mode;
+{ int c = b = c; }
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 3c75a0d..35c06b8 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -3281,10 +3281,10 @@ extract_range_from_binary_expr (value_range *vr,
the range of its operand *VR0 with type OP0_TYPE with resulting type TYPE.
The resulting range is stored in *VR. */
-static void
-extract_range_from_unary_expr_1 (value_range *vr,
- enum tree_code code, tree type,
- value_range *vr0_, tree op0_type)
+void
+extract_range_from_unary_expr (value_range *vr,
+ enum tree_code code, tree type,
+ value_range *vr0_, tree op0_type)
{
value_range vr0 = *vr0_, vrtem0 = VR_INITIALIZER, vrtem1 = VR_INITIALIZER;
@@ -3337,12 +3337,12 @@ extract_range_from_unary_expr_1 (value_range *vr,
if (vr0.type == VR_ANTI_RANGE
&& ranges_from_anti_range (&vr0, &vrtem0, &vrtem1))
{
- extract_range_from_unary_expr_1 (vr, code, type, &vrtem0, op0_type);
+ extract_range_from_unary_expr (vr, code, type, &vrtem0, op0_type);
if (vrtem1.type != VR_UNDEFINED)
{
value_range vrres = VR_INITIALIZER;
- extract_range_from_unary_expr_1 (&vrres, code, type,
- &vrtem1, op0_type);
+ extract_range_from_unary_expr (&vrres, code, type,
+ &vrtem1, op0_type);
vrp_meet (vr, &vrres);
}
return;
@@ -3597,7 +3597,7 @@ extract_range_from_unary_expr (value_range *vr, enum tree_code code,
else
set_value_range_to_varying (&vr0);
- extract_range_from_unary_expr_1 (vr, code, type, &vr0, TREE_TYPE (op0));
+ extract_range_from_unary_expr (vr, code, type, &vr0, TREE_TYPE (op0));
}
diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h
index 7ffb7e7..5cea709 100644
--- a/gcc/tree-vrp.h
+++ b/gcc/tree-vrp.h
@@ -51,4 +51,9 @@ struct GTY(()) value_range
extern void vrp_intersect_ranges (value_range *vr0, value_range *vr1);
extern void vrp_meet (value_range *vr0, const value_range *vr1);
extern void dump_value_range (FILE *, const value_range *);
+extern void extract_range_from_unary_expr (value_range *vr,
+ enum tree_code code,
+ tree type,
+ value_range *vr0_,
+ tree op0_type);