summaryrefslogtreecommitdiffstats
path: root/debian/patches/pr113705.diff
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:58:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:58:36 +0000
commit1d3b23e6bdbf53eb74161c37d8c355c2ec858a19 (patch)
treee279a67ec4f447e99b0754e7964666f7b48b5c05 /debian/patches/pr113705.diff
parentAdding upstream version 14-20240201. (diff)
downloadgcc-14-debian.tar.xz
gcc-14-debian.zip
Adding debian version 14-20240201-3.debian/14-20240201-3debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/patches/pr113705.diff')
-rw-r--r--debian/patches/pr113705.diff93
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 ();
++ }
++}