This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [committed] PR 61095: tsan fallout from wide-int merge


Richard Sandiford <rdsandiford@googlemail.com> writes:
> This PR was due to code in which -(int) foo was suposed to be sign-extended,
> but was being ORed with an unsigned int and so ended up being zero-extended.
> Fixed by using the proper-width type.

As Kostya rightly said in the PR, this should have had a testcase too.

Tested on x86_64-linux-gnu.  It failed before the patch on x86_64,
passes after it, and is skipped for -m32.  OK to install?

Thanks,
Richard


gcc/testsuite/
	PR tree-optimization/61095
	* gcc.dg/torture/pr61095.c: New test.

Index: gcc/testsuite/gcc.dg/torture/pr61095.c
===================================================================
--- /dev/null	2014-05-03 11:58:38.033951363 +0100
+++ gcc/testsuite/gcc.dg/torture/pr61095.c	2014-05-08 08:46:01.203827892 +0100
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-require-effective-target lp64 } */
+
+extern void __attribute__ ((noreturn)) abort (void);
+
+int __attribute__ ((noinline, noclone))
+foo (unsigned long addr) {
+    unsigned long *p = (unsigned long*)((addr & 0xffff83fffffffff8UL) * 4);
+    unsigned long xxx = (unsigned long)(p + 1);
+    return xxx >= 0x3c000000000UL;
+}
+
+int
+main (void)
+{
+  if (foo (0))
+    abort ();
+  if (foo (0x7c0000000000UL))
+    abort ();
+  if (!foo (0xfc0000000000UL))
+    abort ();
+  return 0;
+}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]