public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1553] target/106219 - proprly mark builtins pure via ix86_add_new_builtins
@ 2022-07-07 10:03 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-07-07 10:03 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:8bc243943765f969c0d4625721a9944e9516d013

commit r13-1553-g8bc243943765f969c0d4625721a9944e9516d013
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jul 7 10:46:01 2022 +0200

    target/106219 - proprly mark builtins pure via ix86_add_new_builtins
    
    The target optimize pragma path to initialize extra target specific
    builtins missed handling of the pure_p flag which in turn causes
    extra clobber side-effects of gather builtins leading to unexpected
    issues downhill.
    
            PR target/106219
            * config/i386/i386-builtins.cc (ix86_add_new_builtins): Properly
            set DECL_PURE_P.
    
            * g++.dg/pr106219.C: New testcase.

Diff:
---
 gcc/config/i386/i386-builtins.cc |  2 ++
 gcc/testsuite/g++.dg/pr106219.C  | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/gcc/config/i386/i386-builtins.cc b/gcc/config/i386/i386-builtins.cc
index 96743e6122d..fe7243c3837 100644
--- a/gcc/config/i386/i386-builtins.cc
+++ b/gcc/config/i386/i386-builtins.cc
@@ -385,6 +385,8 @@ ix86_add_new_builtins (HOST_WIDE_INT isa, HOST_WIDE_INT isa2)
 	  ix86_builtins[i] = decl;
 	  if (ix86_builtins_isa[i].const_p)
 	    TREE_READONLY (decl) = 1;
+	  if (ix86_builtins_isa[i].pure_p)
+	    DECL_PURE_P (decl) = 1;
 	}
     }
 
diff --git a/gcc/testsuite/g++.dg/pr106219.C b/gcc/testsuite/g++.dg/pr106219.C
new file mode 100644
index 00000000000..3cad1507d5f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr106219.C
@@ -0,0 +1,31 @@
+// { dg-do compile }
+// { dg-options "-O3" }
+// { dg-additional-options "-march=bdver2" { target x86_64-*-* } }
+
+int max(int __b) {
+  if (0 < __b)
+    return __b;
+  return 0;
+}
+struct Plane {
+  Plane(int, int);
+  int *Row();
+};
+#ifdef __x86_64__
+#pragma GCC target "sse2,ssse3,avx,avx2"
+#endif
+float *ConvolveXSampleAndTranspose_rowp;
+int ConvolveXSampleAndTranspose_res, ConvolveXSampleAndTranspose_r;
+void ConvolveXSampleAndTranspose() {
+  Plane out(0, ConvolveXSampleAndTranspose_res);
+  for (int y;;) {
+    float sum;
+    for (int i = ConvolveXSampleAndTranspose_r; i; ++i)
+      sum += i;
+    for (; ConvolveXSampleAndTranspose_r; ++ConvolveXSampleAndTranspose_r)
+      sum +=
+          ConvolveXSampleAndTranspose_rowp[max(ConvolveXSampleAndTranspose_r)] *
+          ConvolveXSampleAndTranspose_r;
+    out.Row()[y] = sum;
+  }
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-07 10:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 10:03 [gcc r13-1553] target/106219 - proprly mark builtins pure via ix86_add_new_builtins Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).