aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2011-11-10 16:39:32 +0000
committerAndrew Macleod <amacleod@gcc.gnu.org>2011-11-10 16:39:32 +0000
commit154b68db9bee50c8acb1c0440987f4ef176d2a65 (patch)
treeb11770e605e88e4c894d09421e2b55b78d37b982 /gcc/testsuite
parentc8bf99b4e84b9b0783aca23ecc85425cb3569f16 (diff)
downloadgcc-154b68db9bee50c8acb1c0440987f4ef176d2a65.zip
gcc-154b68db9bee50c8acb1c0440987f4ef176d2a65.tar.gz
gcc-154b68db9bee50c8acb1c0440987f4ef176d2a65.tar.bz2
re PR rtl-optimization/51040 (ICE: RTL check: access of elt 1 of 'not' with last elt 0 in gen_rtx_fmt_ee_stat, at ./genrtl.h:33 with __atomic_nand_fetch())
PR rtl-optimization/51040 * optabs.c (expand_atomic_fetch_op): Patchup code for NAND should be AND followed by NOT. * builtins.c (expand_builtin_atomic_fetch_op): Patchup code for NAND should be AND followed by NOT. * testsuite/gcc.dg/atomic-noinline[-aux].c: Test no-inline NAND and patchup code. From-SVN: r181259
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.dg/atomic-noinline-aux.c15
-rw-r--r--gcc/testsuite/gcc.dg/atomic-noinline.c7
2 files changed, 21 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/atomic-noinline-aux.c b/gcc/testsuite/gcc.dg/atomic-noinline-aux.c
index b92fcfc..b05460e 100644
--- a/gcc/testsuite/gcc.dg/atomic-noinline-aux.c
+++ b/gcc/testsuite/gcc.dg/atomic-noinline-aux.c
@@ -40,11 +40,24 @@ char __atomic_fetch_add_1 (char *p, char v, int i)
*p = 1;
}
-short __atomic_fetch_add_2 (short *p, short v, short i)
+short __atomic_fetch_add_2 (short *p, short v, int i)
{
*p = 1;
}
+/* Really perform a NAND. PR51040 showed incorrect calculation of a
+ non-inlined fetch_nand. */
+unsigned char
+__atomic_fetch_nand_1 (unsigned char *p, unsigned char v, int i)
+{
+ unsigned char ret;
+
+ ret = *p;
+ *p = ~(*p & v);
+
+ return ret;
+}
+
int __atomic_is_lock_free (int i, void *p)
{
return 10;
diff --git a/gcc/testsuite/gcc.dg/atomic-noinline.c b/gcc/testsuite/gcc.dg/atomic-noinline.c
index 06a93e0..eb0866e 100644
--- a/gcc/testsuite/gcc.dg/atomic-noinline.c
+++ b/gcc/testsuite/gcc.dg/atomic-noinline.c
@@ -49,6 +49,13 @@ main ()
if (__atomic_is_lock_free (4, 0) != 10)
abort ();
+ /* PR 51040 was caused by arithmetic code not patching up nand_fetch properly
+ when used an an external function. Look for proper return value here. */
+ ac = 0x3C;
+ bc = __atomic_nand_fetch (&ac, 0x0f, __ATOMIC_RELAXED);
+ if (bc != ac)
+ abort ();
+
return 0;
}