From e6a21dd2b9cb1a84d932a7098d98737869091171 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 23 Apr 2012 12:13:39 +0200 Subject: [PATCH] re PR tree-optimization/52891 (ICE in adjust_bool_pattern) PR tree-optimizations/52891 * tree-vect-patterns.c (adjust_bool_pattern): Use build_nonstandard_type even if rhs1 has unsigned INTEGER_TYPE, but with non-standard precision. * gcc.c-torture/compile/pr52891-1.c: New test. * gcc.c-torture/compile/pr52891-2.c: New test. From-SVN: r186694 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 6 ++++++ .../gcc.c-torture/compile/pr52891-1.c | 20 +++++++++++++++++++ .../gcc.c-torture/compile/pr52891-2.c | 12 +++++++++++ gcc/tree-vect-patterns.c | 4 +++- 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr52891-1.c create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr52891-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 74951139573..b204f8268a2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2012-04-23 Jakub Jelinek + + PR tree-optimizations/52891 + * tree-vect-patterns.c (adjust_bool_pattern): Use + build_nonstandard_type even if rhs1 has unsigned INTEGER_TYPE, + but with non-standard precision. + 2012-04-22 Jan Hubicka * tree-ssa-loop-ivopts.c (expr_invariant_in_loop_p): Bail out at NULL tree refs. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2877e72304..f1b50fa39d0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-04-23 Jakub Jelinek + + PR tree-optimizations/52891 + * gcc.c-torture/compile/pr52891-1.c: New test. + * gcc.c-torture/compile/pr52891-2.c: New test. + 2012-04-22 Tobias Burnus PR fortran/53051 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr52891-1.c b/gcc/testsuite/gcc.c-torture/compile/pr52891-1.c new file mode 100644 index 00000000000..e695d1cfcc1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr52891-1.c @@ -0,0 +1,20 @@ +/* PR tree-optimizations/52891 */ + +struct S +{ + int a; + struct T { unsigned c : 10; } b; +} s; + +void +bar (short x, short y, int **p) +{ + if ((x && y) + **p) + while (1); +} + +void +foo (int **p) +{ + bar (s.a, s.b.c, p); +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c b/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c new file mode 100644 index 00000000000..d9fcbd6dd9d --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr52891-2.c @@ -0,0 +1,12 @@ +/* PR tree-optimizations/52891 */ + +struct __attribute__((packed)) S { unsigned s : 22; }; +struct __attribute__((packed)) T { struct S t; } c; +int a, b, d; + +void +foo (void) +{ + if (1 ? (!c.t.s & (d < 0)) < a : 0) + b = 0; +} diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c index 6372a36b3fd..79357f51f5f 100644 --- a/gcc/tree-vect-patterns.c +++ b/gcc/tree-vect-patterns.c @@ -2300,7 +2300,9 @@ adjust_bool_pattern (tree var, tree out_type, tree trueval, default: gcc_assert (TREE_CODE_CLASS (rhs_code) == tcc_comparison); if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE - || !TYPE_UNSIGNED (TREE_TYPE (rhs1))) + || !TYPE_UNSIGNED (TREE_TYPE (rhs1)) + || (TYPE_PRECISION (TREE_TYPE (rhs1)) + != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1))))) { enum machine_mode mode = TYPE_MODE (TREE_TYPE (rhs1)); itype -- 2.30.2