diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d0d34948d1b..543337667dd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-07-08 Jakub Jelinek + + * tree-vect-stmts.c (scan_operand_equal_p): Look through MEM_REF + with SSA_NAME address of POINTER_PLUS_EXPR. Handle MULT_EXPR + and casts in offset when different, both through gimple stmts + and through trees. Rewritten using loops to minimize code duplication + for each operand. + 2019-07-08 Eric Botcazou * emit-rtl.c (set_insn_locations): New function moved from... diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3e24415db85..31ba4200c04 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-07-08 Jakub Jelinek + * g++.dg/vect/simd-6.cc: Replace xfail with target x86. + * g++.dg/vect/simd-9.cc: Likewise. + PR c++/91110 * g++.dg/gomp/pr91110.C: New test. diff --git a/gcc/testsuite/g++.dg/vect/simd-6.cc b/gcc/testsuite/g++.dg/vect/simd-6.cc index 997f7b1cf92..883b769a9b8 100644 --- a/gcc/testsuite/g++.dg/vect/simd-6.cc +++ b/gcc/testsuite/g++.dg/vect/simd-6.cc @@ -1,7 +1,7 @@ // { dg-require-effective-target size32plus } // { dg-additional-options "-fopenmp-simd" } // { dg-additional-options "-mavx" { target avx_runtime } } -// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { xfail *-*-* } } } +// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } #include "../../gcc.dg/vect/tree-vect.h" diff --git a/gcc/testsuite/g++.dg/vect/simd-9.cc b/gcc/testsuite/g++.dg/vect/simd-9.cc index bfef445d121..4c5b0508fbd 100644 --- a/gcc/testsuite/g++.dg/vect/simd-9.cc +++ b/gcc/testsuite/g++.dg/vect/simd-9.cc @@ -1,7 +1,7 @@ // { dg-require-effective-target size32plus } // { dg-additional-options "-fopenmp-simd" } // { dg-additional-options "-mavx" { target avx_runtime } } -// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { xfail *-*-* } } } +// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } #include "../../gcc.dg/vect/tree-vect.h" diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index ead079dac45..10ce2a22f85 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -6334,30 +6334,88 @@ get_group_alias_ptr_type (stmt_vec_info first_stmt_info) static bool scan_operand_equal_p (tree ref1, tree ref2) { - machine_mode mode1, mode2; - poly_int64 bitsize1, bitsize2, bitpos1, bitpos2; - tree offset1, offset2; - int unsignedp1, unsignedp2, reversep1, reversep2; - int volatilep1 = 0, volatilep2 = 0; - tree base1 = get_inner_reference (ref1, &bitsize1, &bitpos1, &offset1, - &mode1, &unsignedp1, &reversep1, - &volatilep1); - tree base2 = get_inner_reference (ref2, &bitsize2, &bitpos2, &offset2, - &mode2, &unsignedp2, &reversep2, - &volatilep2); - if (reversep1 || reversep2 || volatilep1 || volatilep2) + tree ref[2] = { ref1, ref2 }; + poly_int64 bitsize[2], bitpos[2]; + tree offset[2], base[2]; + for (int i = 0; i < 2; ++i) + { + machine_mode mode; + int unsignedp, reversep, volatilep = 0; + base[i] = get_inner_reference (ref[i], &bitsize[i], &bitpos[i], + &offset[i], &mode, &unsignedp, + &reversep, &volatilep); + if (reversep || volatilep || maybe_ne (bitpos[i], 0)) + return false; + if (TREE_CODE (base[i]) == MEM_REF + && offset[i] == NULL_TREE + && TREE_CODE (TREE_OPERAND (base[i], 0)) == SSA_NAME) + { + gimple *def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (base[i], 0)); + if (is_gimple_assign (def_stmt) + && gimple_assign_rhs_code (def_stmt) == POINTER_PLUS_EXPR + && TREE_CODE (gimple_assign_rhs1 (def_stmt)) == ADDR_EXPR + && TREE_CODE (gimple_assign_rhs2 (def_stmt)) == SSA_NAME) + { + if (maybe_ne (mem_ref_offset (base[i]), 0)) + return false; + base[i] = TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 0); + offset[i] = gimple_assign_rhs2 (def_stmt); + } + } + } + + if (!operand_equal_p (base[0], base[1], 0)) return false; - if (!operand_equal_p (base1, base2, 0)) - return false; - if (maybe_ne (bitpos1, 0) || maybe_ne (bitpos2, 0)) - return false; - if (maybe_ne (bitsize1, bitsize2)) - return false; - if (offset1 != offset2 - && (!offset1 - || !offset2 - || !operand_equal_p (offset1, offset2, 0))) + if (maybe_ne (bitsize[0], bitsize[1])) return false; + if (offset[0] != offset[1]) + { + if (!offset[0] || !offset[1]) + return false; + if (!operand_equal_p (offset[0], offset[1], 0)) + { + tree step[2]; + for (int i = 0; i < 2; ++i) + { + step[i] = integer_one_node; + if (TREE_CODE (offset[i]) == SSA_NAME) + { + gimple *def_stmt = SSA_NAME_DEF_STMT (offset[i]); + if (is_gimple_assign (def_stmt) + && gimple_assign_rhs_code (def_stmt) == MULT_EXPR + && (TREE_CODE (gimple_assign_rhs2 (def_stmt)) + == INTEGER_CST)) + { + step[i] = gimple_assign_rhs2 (def_stmt); + offset[i] = gimple_assign_rhs1 (def_stmt); + } + } + else if (TREE_CODE (offset[i]) == MULT_EXPR) + { + step[i] = TREE_OPERAND (offset[i], 1); + offset[i] = TREE_OPERAND (offset[i], 0); + } + tree rhs1 = NULL_TREE; + if (TREE_CODE (offset[i]) == SSA_NAME) + { + gimple *def_stmt = SSA_NAME_DEF_STMT (offset[i]); + if (gimple_assign_cast_p (def_stmt)) + rhs1 = gimple_assign_rhs1 (def_stmt); + } + else if (CONVERT_EXPR_P (offset[i])) + rhs1 = TREE_OPERAND (offset[i], 0); + if (rhs1 + && INTEGRAL_TYPE_P (TREE_TYPE (rhs1)) + && INTEGRAL_TYPE_P (TREE_TYPE (offset[i])) + && (TYPE_PRECISION (TREE_TYPE (offset[i])) + >= TYPE_PRECISION (TREE_TYPE (rhs1)))) + offset[i] = rhs1; + } + if (!operand_equal_p (offset[0], offset[1], 0) + || !operand_equal_p (step[0], step[1], 0)) + return false; + } + } return true; } diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 107c5c9d06f..53125a5ac37 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2019-07-08 Jakub Jelinek + + * testsuite/libgomp.c++/scan-13.C: Replace xfail with target x86. + * testsuite/libgomp.c++/scan-16.C: Likewise. + 2019-07-06 Jakub Jelinek * testsuite/libgomp.c/scan-19.c: New test. diff --git a/libgomp/testsuite/libgomp.c++/scan-13.C b/libgomp/testsuite/libgomp.c++/scan-13.C index eb91297a827..9d0062556d3 100644 --- a/libgomp/testsuite/libgomp.c++/scan-13.C +++ b/libgomp/testsuite/libgomp.c++/scan-13.C @@ -1,7 +1,7 @@ // { dg-require-effective-target size32plus } // { dg-additional-options "-O2 -fopenmp -fdump-tree-vect-details" } // { dg-additional-options "-mavx" { target avx_runtime } } -// { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { xfail *-*-* } } } +// { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } extern "C" void abort (); diff --git a/libgomp/testsuite/libgomp.c++/scan-16.C b/libgomp/testsuite/libgomp.c++/scan-16.C index 025860e8c7a..108660bfbe9 100644 --- a/libgomp/testsuite/libgomp.c++/scan-16.C +++ b/libgomp/testsuite/libgomp.c++/scan-16.C @@ -1,7 +1,7 @@ // { dg-require-effective-target size32plus } // { dg-additional-options "-O2 -fopenmp -fdump-tree-vect-details" } // { dg-additional-options "-mavx" { target avx_runtime } } -// { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { xfail *-*-* } } } +// { dg-final { scan-tree-dump-times "vectorized \[2-6] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } } extern "C" void abort ();