From b168a8dfcc8e22dd932d460159d81291a9fe1ae6 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 26 Nov 2013 22:29:30 +0100 Subject: [PATCH] re PR tree-optimization/59014 (wrong code at -Os and above on x86_64-linux-gnu) PR tree-optimization/59014 * tree-vrp.c (register_edge_assert_for_1): Don't look through conversions from non-integral types or through narrowing conversions. * gcc.c-torture/execute/pr59014.c: New test. From-SVN: r205417 --- gcc/ChangeLog | 5 ++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.c-torture/execute/pr59014.c | 25 +++++++++++++++++++ gcc/tree-vrp.c | 10 +++++--- 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr59014.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7510537f3de8..b50232b79ea7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2013-11-26 Jakub Jelinek + PR tree-optimization/59014 + * tree-vrp.c (register_edge_assert_for_1): Don't look + through conversions from non-integral types or through + narrowing conversions. + PR target/59229 * config/i386/i386.c (device_alg): Fix up formatting. (ix86_expand_set_or_movmem): Handle max_size < epilogue_size_needed diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b92f97e2b716..a2a81170166e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2013-11-26 Jakub Jelinek + PR tree-optimization/59014 + * gcc.c-torture/execute/pr59014.c: New test. + PR target/59229 * gcc.c-torture/execute/pr59229.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59014.c b/gcc/testsuite/gcc.c-torture/execute/pr59014.c new file mode 100644 index 000000000000..10bf81a462f2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr59014.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/59014 */ + +int a = 2, b, c, d; + +int +foo () +{ + for (;; c++) + if ((b > 0) | (a & 1)) + ; + else + { + d = a; + return 0; + } +} + +int +main () +{ + foo (); + if (d != 2) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 171a0f56255e..1ec9c163911b 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -5438,9 +5438,13 @@ register_edge_assert_for_1 (tree op, enum tree_code code, } else if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (op_def))) { - /* Recurse through the type conversion. */ - retval |= register_edge_assert_for_1 (gimple_assign_rhs1 (op_def), - code, e, bsi); + /* Recurse through the type conversion, unless it is a narrowing + conversion or conversion from non-integral type. */ + tree rhs = gimple_assign_rhs1 (op_def); + if (INTEGRAL_TYPE_P (TREE_TYPE (rhs)) + && (TYPE_PRECISION (TREE_TYPE (rhs)) + <= TYPE_PRECISION (TREE_TYPE (op)))) + retval |= register_edge_assert_for_1 (rhs, code, e, bsi); } return retval; -- 2.43.5