Commit df0f6bbb by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/83337 (ICE at -O3 x86_64-linux-gnu: in…

re PR tree-optimization/83337 (ICE at -O3 x86_64-linux-gnu: in interpret_rhs_expr, at tree-scalar-evolution.c:1775)

	PR tree-optimization/83337
	* gimple-loop-interchange.cc (compute_access_stride): Handle bitfield DRs
	properly.

	* gcc.dg/tree-ssa/loop-interchange-14.c: New test.
	* gcc.dg/tree-ssa/loop-interchange-15.c: New test.

From-SVN: r255528
parent 629cc78b
2017-12-10 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/83337
* gimple-loop-interchange.cc (compute_access_stride): Handle bitfield DRs
properly.
2017-12-09 Jakub Jelinek <jakub@redhat.com> 2017-12-09 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/83338 PR tree-optimization/83338
...@@ -1291,6 +1291,30 @@ compute_access_stride (struct loop *loop_nest, struct loop *loop, ...@@ -1291,6 +1291,30 @@ compute_access_stride (struct loop *loop_nest, struct loop *loop,
gcc_assert (loop == bb->loop_father); gcc_assert (loop == bb->loop_father);
tree ref = DR_REF (dr); tree ref = DR_REF (dr);
if (TREE_CODE (ref) == COMPONENT_REF
&& DECL_BIT_FIELD (TREE_OPERAND (ref, 1)))
{
/* We can't take address of bitfields. If the bitfield is at constant
offset from the start of the struct, just use address of the
struct, for analysis of the strides that shouldn't matter. */
if (!TREE_OPERAND (ref, 2)
|| TREE_CODE (TREE_OPERAND (ref, 2)) == INTEGER_CST)
ref = TREE_OPERAND (ref, 0);
/* Otherwise, if we have a bit field representative, use that. */
else if (DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (ref, 1))
!= NULL_TREE)
{
tree repr = DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (ref, 1));
ref = build3 (COMPONENT_REF, TREE_TYPE (repr), TREE_OPERAND (ref, 0),
repr, TREE_OPERAND (ref, 2));
}
/* Otherwise punt. */
else
{
dr->aux = strides;
return;
}
}
tree scev_base = build_fold_addr_expr (ref); tree scev_base = build_fold_addr_expr (ref);
tree scev = analyze_scalar_evolution (loop, scev_base); tree scev = analyze_scalar_evolution (loop, scev_base);
scev = instantiate_scev (loop_preheader_edge (loop_nest), loop, scev); scev = instantiate_scev (loop_preheader_edge (loop_nest), loop, scev);
......
2017-12-10 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/83337
* gcc.dg/tree-ssa/loop-interchange-14.c: New test.
* gcc.dg/tree-ssa/loop-interchange-15.c: New test.
2017-12-09 Steven G. Kargl <kargl@gcc.gnu.org> 2017-12-09 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/82934 PR fortran/82934
......
/* PR tree-optimization/83337 */
/* { dg-do run { target int32plus } } */
/* { dg-options "-O2 -floop-interchange -fdump-tree-linterchange-details" } */
/* Copied from graphite/interchange-5.c */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define N 100
#define M 1111
struct S { int a : 3; int b : 17; int c : 12; };
struct S A[N][M];
static int __attribute__((noinline))
foo (void)
{
int i, j;
for( i = 0; i < M; i++)
for( j = 0; j < N; j++)
A[j][i].b = 5 * A[j][i].b;
return A[0][0].b + A[N-1][M-1].b;
}
extern void abort ();
static void __attribute__((noinline))
init (int i)
{
int j;
for (j = 0; j < M; j++)
A[i][j].b = 2;
}
int
main (void)
{
int i, j, res;
for (i = 0; i < N; i++)
init (i);
res = foo ();
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
if (res != 20)
abort ();
return 0;
}
/* { dg-final { scan-tree-dump-times "Loop_pair<outer:., inner:.> is interchanged" 1 "linterchange"} } */
/* PR tree-optimization/83337 */
/* { dg-do run { target int32plus } } */
/* { dg-options "-O2 -floop-interchange" } */
/* Copied from graphite/interchange-5.c */
#define DEBUG 0
#if DEBUG
#include <stdio.h>
#endif
#define N 100
#define M 1111
extern void abort ();
static void __attribute__((noipa))
foo (int n)
{
int i, j;
struct S { char d[n]; int a : 3; int b : 17; int c : 12; };
struct S A[N][M];
for (i = 0; i < N; i++)
{
asm volatile ("" : : "g" (&A[0][0]) : "memory");
for (j = 0; j < M; j++)
A[i][j].b = 2;
}
asm volatile ("" : : "g" (&A[0][0]) : "memory");
for (i = 0; i < M; i++)
for (j = 0; j < N; j++)
A[j][i].b = 5 * A[j][i].b;
asm volatile ("" : : "g" (&A[0][0]) : "memory");
int res = A[0][0].b + A[N-1][M-1].b;
#if DEBUG
fprintf (stderr, "res = %d \n", res);
#endif
if (res != 20)
abort ();
}
int
main (void)
{
foo (1);
foo (8);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment