gcc/0134-Fix-PR-100925-Limit-some-a-CST1-CST2-optimizations-t.patch
2023-11-30 11:31:49 +08:00

66 lines
1.9 KiB
Diff

From 6995a2f35d0f866068beddae33a8a0e9187861fd Mon Sep 17 00:00:00 2001
From: Andrew Pinski <apinski@marvell.com>
Date: Sat, 5 Jun 2021 21:25:58 -0700
Subject: [PATCH 19/26] Fix PR 100925: Limit some a?CST1:CST2 optimizations to
intergal types only
The problem here is with offset (and pointer) types is we produce
a negative expression when this optimization hits.
It is easier to disable this optimization for all non-integeral types
instead of finding an integer type which is the same precission as the
type to do the negative expression on it.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
PR tree-optimization/100925
* match.pd (a ? CST1 : CST2): Limit transformations
that would produce a negative to integeral types only.
Change !POINTER_TYPE_P to INTEGRAL_TYPE_P also.
gcc/testsuite/ChangeLog:
* g++.dg/torture/pr100925.C: New test.
Reference commit in GCC: d4faa36e7540c573c5dc17850bcd938d0900b2e9
Signed-off-by: Pronin Alexander 00812787 <pronin.alexander@huawei.com>
---
gcc/testsuite/g++.dg/torture/pr100925.C | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/torture/pr100925.C
diff --git a/gcc/testsuite/g++.dg/torture/pr100925.C b/gcc/testsuite/g++.dg/torture/pr100925.C
new file mode 100644
index 000000000..de13950dc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr100925.C
@@ -0,0 +1,24 @@
+// { dg-do compile }
+
+struct QScopedPointerDeleter {
+ static void cleanup(int *);
+};
+class QScopedPointer {
+ typedef int *QScopedPointer::*RestrictedBool;
+
+public:
+ operator RestrictedBool() { return d ? nullptr : &QScopedPointer::d; }
+ void reset() {
+ if (d)
+ QScopedPointerDeleter::cleanup(d);
+ }
+ int *d;
+};
+class DOpenGLPaintDevicePrivate {
+public:
+ QScopedPointer fbo;
+} DOpenGLPaintDeviceresize_d;
+void DOpenGLPaintDeviceresize() {
+ if (DOpenGLPaintDeviceresize_d.fbo)
+ DOpenGLPaintDeviceresize_d.fbo.reset();
+}
--
2.27.0