]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/115646 - ICE with pow shrink-wrapping from bitfield
authorRichard Biener <rguenther@suse.de>
Tue, 25 Jun 2024 14:13:02 +0000 (16:13 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 10 Jan 2025 13:33:55 +0000 (14:33 +0100)
The following makes analysis and transform agree on constraints.

PR tree-optimization/115646
* tree-call-cdce.cc (check_pow): Check for bit_sz values
as allowed by transform.

* gcc.dg/pr115646.c: New testcase.

(cherry picked from commit 453b1d291d1a0f89087ad91cf6b1bed1ec68eff3)

gcc/testsuite/gcc.dg/pr115646.c [new file with mode: 0644]
gcc/tree-call-cdce.cc

diff --git a/gcc/testsuite/gcc.dg/pr115646.c b/gcc/testsuite/gcc.dg/pr115646.c
new file mode 100644 (file)
index 0000000..7938a30
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-require-effective-target int32plus } */
+
+extern double pow(double x, double y);
+
+struct S {
+    unsigned int a : 3, b : 8, c : 21;
+};
+
+void foo (struct S *p)
+{
+  pow (p->c, 42);
+}
index 83991fe373e2126bc647a0294a314148d901755d..91878129835738eee4b6e4ec3de416edf505e686 100644 (file)
@@ -260,7 +260,7 @@ check_pow (gcall *pow_call)
       /* If the type of the base is too wide,
          the resulting shrink wrapping condition
         will be too conservative.  */
-      if (bit_sz > MAX_BASE_INT_BIT_SIZE)
+      if (bit_sz != 8 && bit_sz != 16 && bit_sz != MAX_BASE_INT_BIT_SIZE)
         return false;
 
       return true;