aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2001-12-05 15:17:49 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2001-12-05 15:17:49 +0100
commit1218665b70c0577046f86c7d950832dd703a67d1 (patch)
tree7da38ae698680c56e10b64fb0ae11aa0acbcc3a2 /gcc
parent7254c5fa7355f071477c329a9495a726810a5d63 (diff)
downloadgcc-1218665b70c0577046f86c7d950832dd703a67d1.zip
gcc-1218665b70c0577046f86c7d950832dd703a67d1.tar.gz
gcc-1218665b70c0577046f86c7d950832dd703a67d1.tar.bz2
gcse.c (store_killed_in_insn): Consider pure calls as potential store killers in addition to normal calls.
* gcse.c (store_killed_in_insn): Consider pure calls as potential store killers in addition to normal calls. * gcc.c-torture/execute/20011024-1.c: New test. From-SVN: r47675
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/gcse.c15
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20011024-1.c22
4 files changed, 43 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c3d9d38..cbd8b3c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2001-12-05 Jakub Jelinek <jakub@redhat.com>
+ * gcse.c (store_killed_in_insn): Consider pure calls
+ as potential store killers in addition to normal calls.
+
+2001-12-05 Jakub Jelinek <jakub@redhat.com>
+
* expr.c (expand_expr): When checking promoted value, use
DECL_MODE (exp) and not mode.
diff --git a/gcc/gcse.c b/gcc/gcse.c
index e6cc513..71ee0c6 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -6498,8 +6498,21 @@ store_killed_in_insn (x, insn)
if (GET_CODE (insn) == CALL_INSN)
{
+ /* A normal or pure call might read from pattern,
+ but a const call will not. */
if (CONST_OR_PURE_CALL_P (insn))
- return 0;
+ {
+ rtx link;
+
+ for (link = CALL_INSN_FUNCTION_USAGE (insn);
+ link;
+ link = XEXP (link, 1))
+ if (GET_CODE (XEXP (link, 0)) == USE
+ && GET_CODE (XEXP (XEXP (link, 0), 0)) == MEM
+ && GET_CODE (XEXP (XEXP (XEXP (link, 0), 0), 0)) == SCRATCH)
+ return 1;
+ return 0;
+ }
else
return 1;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5dace7b..95b055c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -6,6 +6,8 @@
* g++.dg/other/anon-union.C: New test.
+ * gcc.c-torture/execute/20011024-1.c: New test.
+
2001-12-04 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.c-torture/execute/20000722-1.x,
diff --git a/gcc/testsuite/gcc.c-torture/execute/20011024-1.c b/gcc/testsuite/gcc.c-torture/execute/20011024-1.c
new file mode 100644
index 0000000..5b871bb
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20011024-1.c
@@ -0,0 +1,22 @@
+/* Test whether store motion recognizes pure functions as potentially reading
+ any memory. */
+
+typedef __SIZE_TYPE__ size_t;
+extern void *memcpy (void *dest, const void *src, size_t n);
+extern size_t strlen (const char *s);
+extern int strcmp (const char *s1, const char *s2) __attribute__((pure));
+
+char buf[50];
+
+static void foo (void)
+{
+ if (memcpy (buf, "abc", 4) != buf) abort ();
+ if (strcmp (buf, "abc")) abort ();
+ memcpy (buf, "abcdefgh", strlen ("abcdefgh") + 1);
+}
+
+int main (void)
+{
+ foo ();
+ return 0;
+}