From: Bin Cheng Date: Tue, 30 Apr 2019 03:00:59 +0000 (+0000) Subject: re PR tree-optimization/90240 (ICE in try_improve_iv_set, at tree-ssa-loop-ivopts... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8c3ce59e2b10ecc3cf7fe9804005405bedc3e280;p=gcc.git re PR tree-optimization/90240 (ICE in try_improve_iv_set, at tree-ssa-loop-ivopts.c:6694) PR tree-optimization/90240 Revert: 2019-04-23 Bin Cheng PR tree-optimization/90078 * tree-ssa-loop-ivopts.c (comp_cost::operator +,-,+=,-+,/=,*=): Add checks for infinite_cost overflow. * gcc/testsuite/g++.dg/tree-ssa/pr90078.C: New test. From-SVN: r270673 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4a0d547709b..99c54020f40 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2019-04-30 Bin Cheng + + PR tree-optimization/90240 + Revert: + 2019-04-23 Bin Cheng + + PR tree-optimization/90078 + * tree-ssa-loop-ivopts.c (comp_cost::operator +,-,+=,-+,/=,*=): Add + checks for infinite_cost overflow. + 2019-04-29 Jeff Law * passes.def: Move -Wrestrict pass after copy propagation. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d64281548b4..eb2599a5e27 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2019-04-30 Bin Cheng + + PR tree-optimization/90240 + Revert: + 2019-04-23 Bin Cheng + + PR tree-optimization/90078 + * gcc/testsuite/g++.dg/tree-ssa/pr90078.C: New test. + 2019-04-29 Vladislav Ivanishin * gcc.dg/uninit-25-gimple.c: New test. diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr90078.C b/gcc/testsuite/g++.dg/tree-ssa/pr90078.C deleted file mode 100644 index e36f50e9d8a..00000000000 --- a/gcc/testsuite/g++.dg/tree-ssa/pr90078.C +++ /dev/null @@ -1,199 +0,0 @@ -// { dg-do compile } -// { dg-options "-std=c++14 -O2 -ftemplate-depth=1000000" } - -template struct Tensor3; -template -struct Tensor3_Expr; - -template struct Tensor4; -template -struct Tensor4_Expr; - -template struct Index -{}; -template struct Number -{ - Number(){}; - operator int() const { return N; } -}; - -template -struct Tensor3 -{ - T data[Tensor_Dim0][Tensor_Dim1][Tensor_Dim2]; - - T operator()(const int N1, const int N2, const int N3) const - { - return data[N1][N2][N3]; - } - - template - Tensor3_Expr, T, - Dim0, Dim1, Dim2, i, j, k> - operator()(const Index, const Index, - const Index) const - { - return Tensor3_Expr, - T, Dim0, Dim1, Dim2, i, j, k>(*this); - } -}; - -template -struct Tensor3_Expr -{ - A iter; - - Tensor3_Expr(const A &a) : iter(a) {} - T operator()(const int N1, const int N2, const int N3) const - { - return iter(N1, N2, N3); - } -}; - -template -struct Tensor3_Expr, T, Dim0, - Dim1, Dim2, i, j, k> -{ - Tensor3 &iter; - - Tensor3_Expr(Tensor3 &a) : iter(a) - {} - T operator()(const int N1, const int N2, const int N3) const - { - return iter(N1, N2, N3); - } -}; - -template -struct Tensor3_times_Tensor3_21 -{ - Tensor3_Expr iterA; - Tensor3_Expr iterB; - - template - T eval(const int N1, const int N2, const int N3, const int N4, - const Number &) const - { - return iterA(N1, N2, CurrentDim - 1) * iterB(CurrentDim - 1, N3, N4) - + eval(N1, N2, N3, N4, Number()); - } - T eval(const int N1, const int N2, const int N3, const int N4, - const Number<1> &) const - { - return iterA(N1, N2, 0) * iterB(0, N3, N4); - } - - Tensor3_times_Tensor3_21( - const Tensor3_Expr &a, - const Tensor3_Expr &b) - : iterA(a), iterB(b) - {} - T operator()(const int &N1, const int &N2, const int &N3, - const int &N4) const - { - return eval(N1, N2, N3, N4, Number()); - } -}; - -template -Tensor4_Expr, - T, Dim0, Dim1, Dim4, Dim5, i, j, l, m> -operator*(const Tensor3_Expr &a, - const Tensor3_Expr &b) -{ - using TensorExpr = Tensor3_times_Tensor3_21; - return Tensor4_Expr( - TensorExpr(a, b)); -}; - -template -struct Tensor4 -{ - T data[Tensor_Dim0][Tensor_Dim1][Tensor_Dim2][Tensor_Dim3]; - - Tensor4() {} - T &operator()(const int N1, const int N2, const int N3, const int N4) - { - return data[N1][N2][N3][N4]; - } - - template - Tensor4_Expr, - T, Dim0, Dim1, Dim2, Dim3, i, j, k, l> - operator()(const Index, const Index, const Index, - const Index) - { - return Tensor4_Expr< - Tensor4, T, Dim0, - Dim1, Dim2, Dim3, i, j, k, l>(*this); - }; -}; - -template -struct Tensor4_Expr -{ - A iter; - - Tensor4_Expr(const A &a) : iter(a) {} - T operator()(const int N1, const int N2, const int N3, const int N4) const - { - return iter(N1, N2, N3, N4); - } -}; - -template -struct Tensor4_Expr, T, Dim0, Dim1, Dim2, - Dim3, i, j, k, l> -{ - Tensor4 &iter; - - Tensor4_Expr(Tensor4 &a) : iter(a) {} - T operator()(const int N1, const int N2, const int N3, const int N4) const - { - return iter(N1, N2, N3, N4); - } - - template - auto &operator=(const Tensor4_Expr &rhs) - { - for(int ii = 0; ii < Dim0; ++ii) - for(int jj = 0; jj < Dim1; ++jj) - for(int kk = 0; kk < Dim2; ++kk) - for(int ll = 0; ll < Dim3; ++ll) - { - iter(ii, jj, kk, ll) = rhs(ii, jj, kk, ll); - } - return *this; - } -}; - -int main() -{ - Tensor3 t1; - Tensor3 t2; - - Index<'l', 100> l; - Index<'m', 100> m; - Index<'k', 1000> k; - Index<'n', 100> n; - Index<'o', 100> o; - - Tensor4 res; - res(l, m, n, o) = t1(l, m, k) * t2(k, n, o); - return 0; -} - diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 4ca1f0e9686..a2b6b2b2312 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -243,9 +243,6 @@ operator+ (comp_cost cost1, comp_cost cost2) if (cost1.infinite_cost_p () || cost2.infinite_cost_p ()) return infinite_cost; - if (cost1.cost + cost2.cost >= infinite_cost.cost) - return infinite_cost; - cost1.cost += cost2.cost; cost1.complexity += cost2.complexity; @@ -259,8 +256,6 @@ operator- (comp_cost cost1, comp_cost cost2) return infinite_cost; gcc_assert (!cost2.infinite_cost_p ()); - if (cost1.cost - cost2.cost >= infinite_cost.cost) - return infinite_cost; cost1.cost -= cost2.cost; cost1.complexity -= cost2.complexity; @@ -281,8 +276,6 @@ comp_cost::operator+= (HOST_WIDE_INT c) if (infinite_cost_p ()) return *this; - if (this->cost + c >= infinite_cost.cost) - return infinite_cost; this->cost += c; return *this; @@ -294,8 +287,6 @@ comp_cost::operator-= (HOST_WIDE_INT c) if (infinite_cost_p ()) return *this; - if (this->cost - c >= infinite_cost.cost) - return infinite_cost; this->cost -= c; return *this; @@ -304,7 +295,6 @@ comp_cost::operator-= (HOST_WIDE_INT c) comp_cost comp_cost::operator/= (HOST_WIDE_INT c) { - gcc_assert (c != 0); if (infinite_cost_p ()) return *this; @@ -319,9 +309,6 @@ comp_cost::operator*= (HOST_WIDE_INT c) if (infinite_cost_p ()) return *this; - if (this->cost * c >= infinite_cost.cost) - return infinite_cost; - this->cost *= c; return *this;