* [committed] PR 61095: tsan fallout from wide-int merge
@ 2014-05-07 18:01 Richard Sandiford
2014-05-08 7:48 ` Richard Sandiford
0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2014-05-07 18:01 UTC (permalink / raw)
To: gcc-patches
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.
Tested on x86_64-linux-gnu and applied as obvious. Sorry for the breakage.
Thanks,
Richard
gcc/
PR tree-optimization/61095
* tree-ssanames.c (get_nonzero_bits): Fix type extension in wi::shwi.
Index: gcc/tree-ssanames.c
===================================================================
--- gcc/tree-ssanames.c 2014-05-07 16:50:15.136064484 +0100
+++ gcc/tree-ssanames.c 2014-05-07 16:50:15.422063737 +0100
@@ -271,7 +271,8 @@ get_nonzero_bits (const_tree name)
{
struct ptr_info_def *pi = SSA_NAME_PTR_INFO (name);
if (pi && pi->align)
- return wi::shwi (-(int) pi->align | pi->misalign, precision);
+ return wi::shwi (-(HOST_WIDE_INT) pi->align
+ | (HOST_WIDE_INT) pi->misalign, precision);
return wi::shwi (-1, precision);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [committed] PR 61095: tsan fallout from wide-int merge
2014-05-07 18:01 [committed] PR 61095: tsan fallout from wide-int merge Richard Sandiford
@ 2014-05-08 7:48 ` Richard Sandiford
2014-05-08 7:56 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2014-05-08 7:48 UTC (permalink / raw)
To: gcc-patches
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;
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [committed] PR 61095: tsan fallout from wide-int merge
2014-05-08 7:48 ` Richard Sandiford
@ 2014-05-08 7:56 ` Richard Biener
0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2014-05-08 7:56 UTC (permalink / raw)
To: GCC Patches, Richard Sandiford
On Thu, May 8, 2014 at 9:48 AM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> 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?
Ok.
Thanks,
Richard.
> 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;
> +}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-08 7:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-07 18:01 [committed] PR 61095: tsan fallout from wide-int merge Richard Sandiford
2014-05-08 7:48 ` Richard Sandiford
2014-05-08 7:56 ` 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).