diff options
Diffstat (limited to '')
-rw-r--r-- | debian/patches/pr113705.diff | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/debian/patches/pr113705.diff b/debian/patches/pr113705.diff new file mode 100644 index 0000000..8ca12df --- /dev/null +++ b/debian/patches/pr113705.diff @@ -0,0 +1,93 @@ +# DP: Proposed patch for PR middle-end/113705 + +2024-02-01 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/113705 + * tree-ssa-math-opts.cc (is_widening_mult_rhs_p): Use wide_int_from + around wi::to_wide in order to compare value in prec precision. + + * g++.dg/opt/pr113705.C: New test. + +--- a/src/gcc/tree-ssa-math-opts.cc ++++ b/src/gcc/tree-ssa-math-opts.cc +@@ -2572,7 +2572,8 @@ is_widening_mult_rhs_p (tree type, tree + if (is_gimple_assign (stmt) + && gimple_assign_rhs_code (stmt) == BIT_AND_EXPR + && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST +- && wi::to_wide (gimple_assign_rhs2 (stmt)) ++ && wide_int::from (wi::to_wide (gimple_assign_rhs2 (stmt)), ++ prec, TYPE_SIGN (TREE_TYPE (rhs))) + == wi::mask (hprec, false, prec)) + *new_rhs_out = gimple_assign_rhs1 (stmt); + else +--- a/src/gcc/testsuite/g++.dg/opt/pr113705.C ++++ b/src/gcc/testsuite/g++.dg/opt/pr113705.C +@@ -0,0 +1,68 @@ ++// PR middle-end/113705 ++// { dg-do compile { target c++17 } } ++// { dg-options "-O2 -w" } ++ ++void foo (); ++template <typename T> struct A : T { long bar () const; }; ++int a; ++ ++template <typename T> ++long ++A<T>::bar () const ++{ ++ return this->baz ()[a]; ++} ++ ++struct B { ++ struct { long b[1]; long c; } u; ++ unsigned d; ++ int e; ++ B (const B &); ++ ~B (); ++ const long *baz () const; ++ unsigned qux () const; ++}; ++ ++B::B (const B &) ++{ ++ if (__builtin_expect (e, 0)) ++ u.c = 0; ++} ++ ++B::~B () ++{ ++ if (__builtin_expect (e, 0)) ++ foo (); ++} ++ ++const long * ++B::baz () const ++{ ++ return u.b; ++} ++ ++unsigned ++B::qux () const ++{ ++ return d; ++} ++ ++struct C { A<B> corge () const; A<B> *f; }; ++ ++A<B> ++C::corge () const ++{ ++ return f[1]; ++} ++ ++void ++test (C r, long *h, unsigned short *d) ++{ ++ for (int j = 0; j < 8; ++j) ++ { ++ A g = r.corge (); ++ *d = g.qux (); ++ for (unsigned i = 0; i < *d; ++i) ++ *h++ = g.bar (); ++ } ++} |