Patchwork [tree-ssa] fix for PR57385

login
register
mail settings
Submitter Alexander Ivchenko
Date May 23, 2013, 10:23 p.m.
Message ID <CACysShiT6kR9AzZRg6H77i0ixOAoX+7OzdMWYYf9K2G9Vx+yfQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/246036/
State New
Headers show

Comments

Alexander Ivchenko - May 23, 2013, 10:23 p.m.
Hi,

The following patch fixes PR57385
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57385)




 Tested and bootsraped on x86-64 linux.
Is it ok for trunk? If yes, should we backport it to 4.8?


thanks,
Alexander
Richard Guenther - May 24, 2013, 8:27 a.m.
On Fri, May 24, 2013 at 12:23 AM, Alexander Ivchenko <aivchenk@gmail.com> wrote:
> Hi,
>
> The following patch fixes PR57385
> (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57385)
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 51e7b9e..cca61e7 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,9 @@
> +2013-05-24  Alexander Ivchenko  <alexander.ivchenko@intel.com>
> +
> +       PR tree-ssa/57385
> +       * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Check
> +       that index is not negative.
> +
>  2013-05-23  Richard Henderson  <rth@redhat.com>
>
>         PR target/56742
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index b1895fb..730e62f 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2013-05-24  Alexander Ivchenko  <alexander.ivchenko@intel.com>
> +
> +       PR tree-ssa/57385
> +       * gcc.dg/tree-ssa/pr57385.c: New test.
> +
>  2013-05-23  Christian Bruel  <christian.bruel@st.com>
>
>         PR debug/57351
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
> b/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
> new file mode 100644
> index 0000000..a04a998
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O1" } */
> +
> +int c;
> +
> +void foo(int f)
> +{
> +  int wbi=-1;
> +  c = (f ? "012346000000000000":"01345:000000006008")[wbi];
> +}
> diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
> index 49d61b0..0e7a74c 100644
> --- a/gcc/tree-ssa-sccvn.c
> +++ b/gcc/tree-ssa-sccvn.c
> @@ -1294,6 +1294,7 @@ fully_constant_vn_reference_p (vn_reference_t ref)
>               == TYPE_MODE (TREE_TYPE (TREE_TYPE (arg0->op0))))
>           && GET_MODE_CLASS (TYPE_MODE (op->type)) == MODE_INT
>           && GET_MODE_SIZE (TYPE_MODE (op->type)) == 1
> +         && tree_int_cst_sgn (op->op0) >= 0
>           && compare_tree_int (op->op0, TREE_STRING_LENGTH (arg0->op0)) < 0)
>         return build_int_cst_type (op->type,
>                                    (TREE_STRING_POINTER (arg0->op0)
>
>
>
>  Tested and bootsraped on x86-64 linux.
> Is it ok for trunk? If yes, should we backport it to 4.8?

Ok for trunk and 4.8 after 4.8.1 is out.

Thanks,
Richard.

>
> thanks,
> Alexander
Kirill Yukhin - May 24, 2013, 9:18 a.m.
Adding back community

On Fri, May 24, 2013 at 1:15 PM, Kirill Yukhin <kirill.yukhin@gmail.com> wrote:
>>
>> Ok for trunk and 4.8 after 4.8.1 is out.
>>
>
> Checked in to trunk:
> http://gcc.gnu.org/ml/gcc-cvs/2013-05/msg00803.html (+
> http://gcc.gnu.org/ml/gcc-cvs/2013-05/msg00804.html for missed test).
> And 4.8 branch: http://gcc.gnu.org/ml/gcc-cvs/2013-05/msg00805.html
>
> Thanks, K

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 51e7b9e..cca61e7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@ 
+2013-05-24  Alexander Ivchenko  <alexander.ivchenko@intel.com>
+
+       PR tree-ssa/57385
+       * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Check
+       that index is not negative.
+
 2013-05-23  Richard Henderson  <rth@redhat.com>

        PR target/56742
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b1895fb..730e62f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@ 
+2013-05-24  Alexander Ivchenko  <alexander.ivchenko@intel.com>
+
+       PR tree-ssa/57385
+       * gcc.dg/tree-ssa/pr57385.c: New test.
+
 2013-05-23  Christian Bruel  <christian.bruel@st.com>

        PR debug/57351
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
b/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
new file mode 100644
index 0000000..a04a998
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+int c;
+
+void foo(int f)
+{
+  int wbi=-1;
+  c = (f ? "012346000000000000":"01345:000000006008")[wbi];
+}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 49d61b0..0e7a74c 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1294,6 +1294,7 @@  fully_constant_vn_reference_p (vn_reference_t ref)
              == TYPE_MODE (TREE_TYPE (TREE_TYPE (arg0->op0))))
          && GET_MODE_CLASS (TYPE_MODE (op->type)) == MODE_INT
          && GET_MODE_SIZE (TYPE_MODE (op->type)) == 1
+         && tree_int_cst_sgn (op->op0) >= 0
          && compare_tree_int (op->op0, TREE_STRING_LENGTH (arg0->op0)) < 0)
        return build_int_cst_type (op->type,
                                   (TREE_STRING_POINTER (arg0->op0)