linux-snps-arc.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [ARC] PR 88409: miscompilation due to missing cc clobber in longlong.h macros
@ 2019-03-28 23:02 Vineet Gupta
  2019-03-29  0:07 ` Marc Glisse
  0 siblings, 1 reply; 7+ messages in thread
From: Vineet Gupta @ 2019-03-28 23:02 UTC (permalink / raw)
  To: linux-snps-arc

simple test such as below was failing.

| void main(int argc, char *argv[])
| {
|    size_t total_time = 115424;                       // expected 115.424
|    double secs = (double)total_time/(double)1000;
|    printf("%s %d %lf\n", "secs", total_time, secs);  // prints 113.504
|    printf("%d\n", (size_t)secs);
| }

The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem()
which uses the __arc__ specific inline asm macros from longlong.h which
were causing miscompilation.

include/
2019-03-28  Vineet Gupta <vgupta at synopsys.com>

	PR 89877

	* longlong.h [__arc__] (add_ssaaaa): Add cc clobber
	(sub_ddmmss): Likewise.

Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
---
 include/ChangeLog  | 7 +++++++
 include/longlong.h | 6 ++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/ChangeLog b/include/ChangeLog
index be08141deeb9..96d967d10a52 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,10 @@
+2019-03-28  Vineet Gupta <vgupta at synopsys.com>
+
+	PR 89877
+
+	* longlong.h [__arc__] (add_ssaaaa): Add cc clobber
+	(sub_ddmmss): Likewise.
+
 2019-02-11  Philippe Waroquiers  <philippe.waroquiers at skynet.be>
 
 	* splay-tree.h (splay_tree_delete_key_fn): Update comment.
diff --git a/include/longlong.h b/include/longlong.h
index 3dd8dc3aa80c..1f0ce4204255 100644
--- a/include/longlong.h
+++ b/include/longlong.h
@@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
 	   : "%r" ((USItype) (ah)),					\
 	     "rICal" ((USItype) (bh)),					\
 	     "%r" ((USItype) (al)),					\
-	     "rICal" ((USItype) (bl)))
+	     "rICal" ((USItype) (bl))					\
+	   : "cc")
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
   __asm__ ("sub.f	%1, %4, %5\n\tsbc	%0, %2, %3"		\
 	   : "=r" ((USItype) (sh)),					\
@@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
 	   : "r" ((USItype) (ah)),					\
 	     "rICal" ((USItype) (bh)),					\
 	     "r" ((USItype) (al)),					\
-	     "rICal" ((USItype) (bl)))
+	     "rICal" ((USItype) (bl))					\
+	   : "cc")
 
 #define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
 #ifdef __ARC_NORM__
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] [ARC] PR 88409: miscompilation due to missing cc clobber in longlong.h macros
  2019-03-28 23:02 [PATCH] [ARC] PR 88409: miscompilation due to missing cc clobber in longlong.h macros Vineet Gupta
@ 2019-03-29  0:07 ` Marc Glisse
  2019-03-29  0:20   ` Vineet Gupta
  0 siblings, 1 reply; 7+ messages in thread
From: Marc Glisse @ 2019-03-29  0:07 UTC (permalink / raw)
  To: linux-snps-arc

On Thu, 28 Mar 2019, Vineet Gupta wrote:

> simple test such as below was failing.
>
> | void main(int argc, char *argv[])
> | {
> |    size_t total_time = 115424;                       // expected 115.424
> |    double secs = (double)total_time/(double)1000;
> |    printf("%s %d %lf\n", "secs", total_time, secs);  // prints 113.504
> |    printf("%d\n", (size_t)secs);
> | }
>
> The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem()
> which uses the __arc__ specific inline asm macros from longlong.h which
> were causing miscompilation.

Hello,

do you intend to post similar patches for glibc and gmp, which both have a 
similar longlong.h?

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] [ARC] PR 88409: miscompilation due to missing cc clobber in longlong.h macros
  2019-03-29  0:07 ` Marc Glisse
@ 2019-03-29  0:20   ` Vineet Gupta
  0 siblings, 0 replies; 7+ messages in thread
From: Vineet Gupta @ 2019-03-29  0:20 UTC (permalink / raw)
  To: linux-snps-arc

On 3/28/19 5:07 PM, Marc Glisse wrote:
> On Thu, 28 Mar 2019, Vineet Gupta wrote:
>
>> simple test such as below was failing.
>>
>> | void main(int argc, char *argv[])
>> | {
>> |    size_t total_time = 115424;                       // expected 115.424
>> |    double secs = (double)total_time/(double)1000;
>> |    printf("%s %d %lf\n", "secs", total_time, secs);  // prints 113.504
>> |    printf("%d\n", (size_t)secs);
>> | }
>>
>> The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem()
>> which uses the __arc__ specific inline asm macros from longlong.h which
>> were causing miscompilation.
> Hello,
>
> do you intend to post similar patches for glibc and gmp, which both have a 
> similar longlong.h?

Yeah, glibc typically "syncs" longlong.h from gcc so once gcc patch is merged,
I'll post a sync patch to glibc.
Good tip about gmp, I wasn't aware of that. I suppose I could post there too once
dust settles on gcc side.

Thx,
-Vinet

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] [ARC] PR 88409: miscompilation due to missing cc clobber in longlong.h macros
  2019-04-03 17:28   ` Vineet Gupta
@ 2019-04-09 17:54     ` Claudiu Zissulescu
  0 siblings, 0 replies; 7+ messages in thread
From: Claudiu Zissulescu @ 2019-04-09 17:54 UTC (permalink / raw)
  To: linux-snps-arc

Done.

On Wed, Apr 3, 2019@8:28 PM Vineet Gupta <vineet.gupta1@synopsys.com> wrote:
>
> On 4/3/19 2:53 AM, Claudiu Zissulescu wrote:
> > Pushed, thank you for your contribution,
> > Claudiu
>
> Thx, can this be backported to gcc-8-stable please which is what glibc folks use
> for testing !
>
> -Vineet
>
> >
> > On Tue, Apr 2, 2019@9:27 PM Vineet Gupta <vineet.gupta1@synopsys.com> wrote:
> >> simple test such as below was failing.
> >>
> >> | void main(int argc, char *argv[])
> >> | {
> >> |    size_t total_time = 115424;                       // expected 115.424
> >> |    double secs = (double)total_time/(double)1000;
> >> |    printf("%s %d %lf\n", "secs", total_time, secs);  // prints 113.504
> >> |    printf("%d\n", (size_t)secs);
> >> | }
> >>
> >> The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem()
> >> which uses the __arc__ specific inline asm macros from longlong.h which
> >> were causing miscompilation.
> >>
> >> include/
> >> 2019-03-28  Vineet Gupta <vgupta at synopsys.com>
> >>
> >>         PR 89877
> >>
> >>         * longlong.h [__arc__] (add_ssaaaa): Add cc clobber
> >>         (sub_ddmmss): Likewise.
> >>
> >> Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
> >> ---
> >>  include/ChangeLog  | 7 +++++++
> >>  include/longlong.h | 6 ++++--
> >>  2 files changed, 11 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/include/ChangeLog b/include/ChangeLog
> >> index be08141deeb9..96d967d10a52 100644
> >> --- a/include/ChangeLog
> >> +++ b/include/ChangeLog
> >> @@ -1,3 +1,10 @@
> >> +2019-03-28  Vineet Gupta <vgupta at synopsys.com>
> >> +
> >> +       PR 89877
> >> +
> >> +       * longlong.h [__arc__] (add_ssaaaa): Add cc clobber
> >> +       (sub_ddmmss): Likewise.
> >> +
> >>  2019-02-11  Philippe Waroquiers  <philippe.waroquiers at skynet.be>
> >>
> >>         * splay-tree.h (splay_tree_delete_key_fn): Update comment.
> >> diff --git a/include/longlong.h b/include/longlong.h
> >> index 3dd8dc3aa80c..1f0ce4204255 100644
> >> --- a/include/longlong.h
> >> +++ b/include/longlong.h
> >> @@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
> >>            : "%r" ((USItype) (ah)),                                     \
> >>              "rICal" ((USItype) (bh)),                                  \
> >>              "%r" ((USItype) (al)),                                     \
> >> -            "rICal" ((USItype) (bl)))
> >> +            "rICal" ((USItype) (bl))                                   \
> >> +          : "cc")
> >>  #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
> >>    __asm__ ("sub.f      %1, %4, %5\n\tsbc       %0, %2, %3"             \
> >>            : "=r" ((USItype) (sh)),                                     \
> >> @@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
> >>            : "r" ((USItype) (ah)),                                      \
> >>              "rICal" ((USItype) (bh)),                                  \
> >>              "r" ((USItype) (al)),                                      \
> >> -            "rICal" ((USItype) (bl)))
> >> +            "rICal" ((USItype) (bl))                                   \
> >> +          : "cc")
> >>
> >>  #define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
> >>  #ifdef __ARC_NORM__
> >> --
> >> 2.7.4
> >>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] [ARC] PR 88409: miscompilation due to missing cc clobber in longlong.h macros
  2019-04-03  9:53 ` Claudiu Zissulescu
@ 2019-04-03 17:28   ` Vineet Gupta
  2019-04-09 17:54     ` Claudiu Zissulescu
  0 siblings, 1 reply; 7+ messages in thread
From: Vineet Gupta @ 2019-04-03 17:28 UTC (permalink / raw)
  To: linux-snps-arc

On 4/3/19 2:53 AM, Claudiu Zissulescu wrote:
> Pushed, thank you for your contribution,
> Claudiu

Thx, can this be backported to gcc-8-stable please which is what glibc folks use
for testing !

-Vineet

>
> On Tue, Apr 2, 2019@9:27 PM Vineet Gupta <vineet.gupta1@synopsys.com> wrote:
>> simple test such as below was failing.
>>
>> | void main(int argc, char *argv[])
>> | {
>> |    size_t total_time = 115424;                       // expected 115.424
>> |    double secs = (double)total_time/(double)1000;
>> |    printf("%s %d %lf\n", "secs", total_time, secs);  // prints 113.504
>> |    printf("%d\n", (size_t)secs);
>> | }
>>
>> The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem()
>> which uses the __arc__ specific inline asm macros from longlong.h which
>> were causing miscompilation.
>>
>> include/
>> 2019-03-28  Vineet Gupta <vgupta at synopsys.com>
>>
>>         PR 89877
>>
>>         * longlong.h [__arc__] (add_ssaaaa): Add cc clobber
>>         (sub_ddmmss): Likewise.
>>
>> Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
>> ---
>>  include/ChangeLog  | 7 +++++++
>>  include/longlong.h | 6 ++++--
>>  2 files changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/ChangeLog b/include/ChangeLog
>> index be08141deeb9..96d967d10a52 100644
>> --- a/include/ChangeLog
>> +++ b/include/ChangeLog
>> @@ -1,3 +1,10 @@
>> +2019-03-28  Vineet Gupta <vgupta at synopsys.com>
>> +
>> +       PR 89877
>> +
>> +       * longlong.h [__arc__] (add_ssaaaa): Add cc clobber
>> +       (sub_ddmmss): Likewise.
>> +
>>  2019-02-11  Philippe Waroquiers  <philippe.waroquiers at skynet.be>
>>
>>         * splay-tree.h (splay_tree_delete_key_fn): Update comment.
>> diff --git a/include/longlong.h b/include/longlong.h
>> index 3dd8dc3aa80c..1f0ce4204255 100644
>> --- a/include/longlong.h
>> +++ b/include/longlong.h
>> @@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
>>            : "%r" ((USItype) (ah)),                                     \
>>              "rICal" ((USItype) (bh)),                                  \
>>              "%r" ((USItype) (al)),                                     \
>> -            "rICal" ((USItype) (bl)))
>> +            "rICal" ((USItype) (bl))                                   \
>> +          : "cc")
>>  #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
>>    __asm__ ("sub.f      %1, %4, %5\n\tsbc       %0, %2, %3"             \
>>            : "=r" ((USItype) (sh)),                                     \
>> @@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
>>            : "r" ((USItype) (ah)),                                      \
>>              "rICal" ((USItype) (bh)),                                  \
>>              "r" ((USItype) (al)),                                      \
>> -            "rICal" ((USItype) (bl)))
>> +            "rICal" ((USItype) (bl))                                   \
>> +          : "cc")
>>
>>  #define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
>>  #ifdef __ARC_NORM__
>> --
>> 2.7.4
>>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] [ARC] PR 88409: miscompilation due to missing cc clobber in longlong.h macros
  2019-04-02 18:27 Vineet Gupta
@ 2019-04-03  9:53 ` Claudiu Zissulescu
  2019-04-03 17:28   ` Vineet Gupta
  0 siblings, 1 reply; 7+ messages in thread
From: Claudiu Zissulescu @ 2019-04-03  9:53 UTC (permalink / raw)
  To: linux-snps-arc

Pushed, thank you for your contribution,
Claudiu

On Tue, Apr 2, 2019@9:27 PM Vineet Gupta <vineet.gupta1@synopsys.com> wrote:
>
> simple test such as below was failing.
>
> | void main(int argc, char *argv[])
> | {
> |    size_t total_time = 115424;                       // expected 115.424
> |    double secs = (double)total_time/(double)1000;
> |    printf("%s %d %lf\n", "secs", total_time, secs);  // prints 113.504
> |    printf("%d\n", (size_t)secs);
> | }
>
> The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem()
> which uses the __arc__ specific inline asm macros from longlong.h which
> were causing miscompilation.
>
> include/
> 2019-03-28  Vineet Gupta <vgupta at synopsys.com>
>
>         PR 89877
>
>         * longlong.h [__arc__] (add_ssaaaa): Add cc clobber
>         (sub_ddmmss): Likewise.
>
> Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
> ---
>  include/ChangeLog  | 7 +++++++
>  include/longlong.h | 6 ++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/include/ChangeLog b/include/ChangeLog
> index be08141deeb9..96d967d10a52 100644
> --- a/include/ChangeLog
> +++ b/include/ChangeLog
> @@ -1,3 +1,10 @@
> +2019-03-28  Vineet Gupta <vgupta at synopsys.com>
> +
> +       PR 89877
> +
> +       * longlong.h [__arc__] (add_ssaaaa): Add cc clobber
> +       (sub_ddmmss): Likewise.
> +
>  2019-02-11  Philippe Waroquiers  <philippe.waroquiers at skynet.be>
>
>         * splay-tree.h (splay_tree_delete_key_fn): Update comment.
> diff --git a/include/longlong.h b/include/longlong.h
> index 3dd8dc3aa80c..1f0ce4204255 100644
> --- a/include/longlong.h
> +++ b/include/longlong.h
> @@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
>            : "%r" ((USItype) (ah)),                                     \
>              "rICal" ((USItype) (bh)),                                  \
>              "%r" ((USItype) (al)),                                     \
> -            "rICal" ((USItype) (bl)))
> +            "rICal" ((USItype) (bl))                                   \
> +          : "cc")
>  #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
>    __asm__ ("sub.f      %1, %4, %5\n\tsbc       %0, %2, %3"             \
>            : "=r" ((USItype) (sh)),                                     \
> @@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
>            : "r" ((USItype) (ah)),                                      \
>              "rICal" ((USItype) (bh)),                                  \
>              "r" ((USItype) (al)),                                      \
> -            "rICal" ((USItype) (bl)))
> +            "rICal" ((USItype) (bl))                                   \
> +          : "cc")
>
>  #define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
>  #ifdef __ARC_NORM__
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] [ARC] PR 88409: miscompilation due to missing cc clobber in longlong.h macros
@ 2019-04-02 18:27 Vineet Gupta
  2019-04-03  9:53 ` Claudiu Zissulescu
  0 siblings, 1 reply; 7+ messages in thread
From: Vineet Gupta @ 2019-04-02 18:27 UTC (permalink / raw)
  To: linux-snps-arc

simple test such as below was failing.

| void main(int argc, char *argv[])
| {
|    size_t total_time = 115424;                       // expected 115.424
|    double secs = (double)total_time/(double)1000;
|    printf("%s %d %lf\n", "secs", total_time, secs);  // prints 113.504
|    printf("%d\n", (size_t)secs);
| }

The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem()
which uses the __arc__ specific inline asm macros from longlong.h which
were causing miscompilation.

include/
2019-03-28  Vineet Gupta <vgupta at synopsys.com>

	PR 89877

	* longlong.h [__arc__] (add_ssaaaa): Add cc clobber
	(sub_ddmmss): Likewise.

Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
---
 include/ChangeLog  | 7 +++++++
 include/longlong.h | 6 ++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/ChangeLog b/include/ChangeLog
index be08141deeb9..96d967d10a52 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,10 @@
+2019-03-28  Vineet Gupta <vgupta at synopsys.com>
+
+	PR 89877
+
+	* longlong.h [__arc__] (add_ssaaaa): Add cc clobber
+	(sub_ddmmss): Likewise.
+
 2019-02-11  Philippe Waroquiers  <philippe.waroquiers at skynet.be>
 
 	* splay-tree.h (splay_tree_delete_key_fn): Update comment.
diff --git a/include/longlong.h b/include/longlong.h
index 3dd8dc3aa80c..1f0ce4204255 100644
--- a/include/longlong.h
+++ b/include/longlong.h
@@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
 	   : "%r" ((USItype) (ah)),					\
 	     "rICal" ((USItype) (bh)),					\
 	     "%r" ((USItype) (al)),					\
-	     "rICal" ((USItype) (bl)))
+	     "rICal" ((USItype) (bl))					\
+	   : "cc")
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
   __asm__ ("sub.f	%1, %4, %5\n\tsbc	%0, %2, %3"		\
 	   : "=r" ((USItype) (sh)),					\
@@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
 	   : "r" ((USItype) (ah)),					\
 	     "rICal" ((USItype) (bh)),					\
 	     "r" ((USItype) (al)),					\
-	     "rICal" ((USItype) (bl)))
+	     "rICal" ((USItype) (bl))					\
+	   : "cc")
 
 #define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
 #ifdef __ARC_NORM__
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-09 17:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-28 23:02 [PATCH] [ARC] PR 88409: miscompilation due to missing cc clobber in longlong.h macros Vineet Gupta
2019-03-29  0:07 ` Marc Glisse
2019-03-29  0:20   ` Vineet Gupta
2019-04-02 18:27 Vineet Gupta
2019-04-03  9:53 ` Claudiu Zissulescu
2019-04-03 17:28   ` Vineet Gupta
2019-04-09 17:54     ` Claudiu Zissulescu

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 NNTP newsgroup(s).