public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
@ 2017-03-29 21:20 Peter Bergner
  2017-03-29 22:36 ` Segher Boessenkool
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Bergner @ 2017-03-29 21:20 UTC (permalink / raw)
  To: GCC Patches; +Cc: Segher Boessenkool, David Edelsohn, Bill Schmidt

PR80246 shows a problem with the dxex, dxexq, diex and diexq insn patterns,
that shows up when calling their associated builtins.  The dxex and dxexq
instructions are defined to return 64-bit signed integers (in a FP register),
but the output mode of their patterns is _Decimal64/_Decimal128.
This leads to corrupting of the returned value if we assign the return
value to a integer type variable (ie, we do a cast).  A similar problem
exists with the diex and diexq patterns on their input operand that
is supposed to hold a 64-bit signed integer.

This patch fixes the patterns to use DImode (ie, a 64-bit integer).
Google shows no use of the builtins anywhere except in the GCC source,
so it should be safe to change these.  If there were users, they would
have noticed how broken the builtins were.

This passed bootstrap and regtesting on powerpc64le-linux and
powerpc64-linux (testsuite in both 32-bit and 64-bit).  Ok for mainline?
Ok for the open release branches too?

Peter

gcc/
	PR target/80246
	* config/rs6000/dfp.md (dfp_dxex_<mode>): Update mode of operand 0.
	(dfp_diex_<mode>): Update mode of operand 1.
	* doc/extend.texi (dxex, dxexq): Document change to return type.
	(diex, diexq): Document change to argument type.

gcc/testsuite/
	PR target/80246
	* gcc.target/powerpc/dfp-builtin-1.c (dxex, dxexq): Update return types.
	(diex, diexq): Update argment types.
	* gcc.target/powerpc/pr80246.c: New test.


Index: gcc/config/rs6000/dfp.md
===================================================================
--- gcc/config/rs6000/dfp.md	(revision 246539)
+++ gcc/config/rs6000/dfp.md	(working copy)
@@ -348,9 +348,9 @@
   [(set_attr "type" "dfp")])
 
 (define_insn "dfp_dxex_<mode>"
-  [(set (match_operand:D64_D128 0 "gpc_reg_operand" "=d")
-	(unspec:D64_D128 [(match_operand:D64_D128 1 "gpc_reg_operand" "d")]
-			 UNSPEC_DXEX))]
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
+	(unspec:DI [(match_operand:D64_D128 1 "gpc_reg_operand" "d")]
+		   UNSPEC_DXEX))]
   "TARGET_DFP"
   "dxex<dfp_suffix> %0,%1"
   [(set_attr "type" "dfp")])
@@ -357,7 +357,7 @@
 
 (define_insn "dfp_diex_<mode>"
   [(set (match_operand:D64_D128 0 "gpc_reg_operand" "=d")
-	(unspec:D64_D128 [(match_operand:D64_D128 1 "gpc_reg_operand" "d")
+	(unspec:D64_D128 [(match_operand:DI 1 "gpc_reg_operand" "d")
 			  (match_operand:D64_D128 2 "gpc_reg_operand" "d")]
 			 UNSPEC_DXEX))]
   "TARGET_DFP"
Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi	(revision 246539)
+++ gcc/doc/extend.texi	(working copy)
@@ -15427,14 +15427,14 @@
 of processors when hardware decimal floating point
 (@option{-mhard-dfp}) is available:
 @smallexample
-_Decimal64 __builtin_dxex (_Decimal64);
-_Decimal128 __builtin_dxexq (_Decimal128);
+long long __builtin_dxex (_Decimal64);
+long long __builtin_dxexq (_Decimal128);
 _Decimal64 __builtin_ddedpd (int, _Decimal64);
 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
 _Decimal64 __builtin_denbcd (int, _Decimal64);
 _Decimal128 __builtin_denbcdq (int, _Decimal128);
-_Decimal64 __builtin_diex (_Decimal64, _Decimal64);
-_Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
+_Decimal64 __builtin_diex (long long, _Decimal64);
+_Decimal128 _builtin_diexq (long long, _Decimal128);
 _Decimal64 __builtin_dscli (_Decimal64, int);
 _Decimal128 __builtin_dscliq (_Decimal128, int);
 _Decimal64 __builtin_dscri (_Decimal64, int);
Index: gcc/testsuite/gcc.target/powerpc/dfp-builtin-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/dfp-builtin-1.c	(revision 246539)
+++ gcc/testsuite/gcc.target/powerpc/dfp-builtin-1.c	(working copy)
@@ -52,7 +52,7 @@
   return __builtin_denbcd (1, a);
 }
 
-_Decimal64
+long long
 do_xex (_Decimal64 a)
 {
   return __builtin_dxex (a);
@@ -59,7 +59,7 @@
 }
 
 _Decimal64
-do_iex (_Decimal64 a, _Decimal64 b)
+do_iex (long long a, _Decimal64 b)
 {
   return __builtin_diex (a, b);
 }
Index: gcc/testsuite/gcc.target/powerpc/pr80246.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr80246.c	(nonexistent)
+++ gcc/testsuite/gcc.target/powerpc/pr80246.c	(working copy)
@@ -0,0 +1,40 @@
+/* { dg-do compile { target { powerpc*-*-linux* } } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
+/* { dg-require-effective-target dfp } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times "dxex "  1 } } */
+/* { dg-final { scan-assembler-times "dxexq " 1 } } */
+/* { dg-final { scan-assembler-times "diex "  1 } } */
+/* { dg-final { scan-assembler-times "diexq " 1 } } */
+/* { dg-final { scan-assembler-not "bl __builtin" } } */
+/* { dg-final { scan-assembler-not "drintn\\." } } */
+/* { dg-final { scan-assembler-not "drintnq\\." } } */
+/* { dg-final { scan-assembler-not "dctfix" } } */
+/* { dg-final { scan-assembler-not "dctfixq" } } */
+/* { dg-final { scan-assembler-not "dcffix" } } */
+/* { dg-final { scan-assembler-not "dcffixq" } } */
+
+long long
+do_xex (_Decimal64 arg)
+{
+  return __builtin_dxex (arg);
+}
+
+long long
+do_xexq (_Decimal128 arg)
+{
+  return __builtin_dxexq (arg);
+}
+
+_Decimal64
+do_iex (long long exp, _Decimal64 arg)
+{
+  return __builtin_diex (exp, arg);
+}
+
+_Decimal128
+do_iexq (long long exp, _Decimal128 arg)
+{
+  return __builtin_diexq (exp, arg);
+}

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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-03-29 21:20 [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types Peter Bergner
@ 2017-03-29 22:36 ` Segher Boessenkool
  2017-03-30  7:33   ` Peter Bergner
  0 siblings, 1 reply; 17+ messages in thread
From: Segher Boessenkool @ 2017-03-29 22:36 UTC (permalink / raw)
  To: Peter Bergner; +Cc: GCC Patches, David Edelsohn, Bill Schmidt

Hi!

On Wed, Mar 29, 2017 at 04:11:19PM -0500, Peter Bergner wrote:
> This passed bootstrap and regtesting on powerpc64le-linux and
> powerpc64-linux (testsuite in both 32-bit and 64-bit).  Ok for mainline?
> Ok for the open release branches too?

Okay.  A few nits below.  Thanks!


> gcc/testsuite/
> 	PR target/80246
> 	* gcc.target/powerpc/dfp-builtin-1.c (dxex, dxexq): Update return types.
> 	(diex, diexq): Update argment types.

Typo ("argument").

> Index: gcc/testsuite/gcc.target/powerpc/pr80246.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr80246.c	(nonexistent)
> +++ gcc/testsuite/gcc.target/powerpc/pr80246.c	(working copy)
> @@ -0,0 +1,40 @@
> +/* { dg-do compile { target { powerpc*-*-linux* } } } */
> +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
> +/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
> +/* { dg-require-effective-target dfp } */

You can leave off the default arguments "*" "".  Do we really need to
explicitly skip on Darwin and SPE if there is a test for DFP anyway?

> +/* { dg-final { scan-assembler-times "dxex "  1 } } */
> +/* { dg-final { scan-assembler-times "dxexq " 1 } } */
> +/* { dg-final { scan-assembler-times "diex "  1 } } */
> +/* { dg-final { scan-assembler-times "diexq " 1 } } */
> +/* { dg-final { scan-assembler-not "bl __builtin" } } */
> +/* { dg-final { scan-assembler-not "drintn\\." } } */
> +/* { dg-final { scan-assembler-not "drintnq\\." } } */
> +/* { dg-final { scan-assembler-not "dctfix" } } */
> +/* { dg-final { scan-assembler-not "dctfixq" } } */

If there is no "dctfix" there surely is no "dctfixq" either (i.e., your
regexen aren't very tight).


Segher

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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-03-29 22:36 ` Segher Boessenkool
@ 2017-03-30  7:33   ` Peter Bergner
  2017-03-30 16:21     ` Peter Bergner
  2017-03-30 17:45     ` Segher Boessenkool
  0 siblings, 2 replies; 17+ messages in thread
From: Peter Bergner @ 2017-03-30  7:33 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches, David Edelsohn, Bill Schmidt

On 3/29/17 5:28 PM, Segher Boessenkool wrote:
> Typo ("argument").

Oops! :-)



>> +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
>> +/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
>> +/* { dg-require-effective-target dfp } */
> 
> You can leave off the default arguments "*" "".  Do we really need to
> explicitly skip on Darwin and SPE if there is a test for DFP anyway?

Good question.  I just cut pasted the above from another test,
but I think you are correct we don't need those.  I'll remove them.


>> +/* { dg-final { scan-assembler-not "drintn\\." } } */
>> +/* { dg-final { scan-assembler-not "drintnq\\." } } */
>> +/* { dg-final { scan-assembler-not "dctfix" } } */
>> +/* { dg-final { scan-assembler-not "dctfixq" } } */
> 
> If there is no "dctfix" there surely is no "dctfixq" either (i.e., your
> regexen aren't very tight).

Ahh, true.  I suppose I could also just look for "drintn" too,
since that would catch both drintn. and drintnq., ok with that
change?

Peter


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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-03-30  7:33   ` Peter Bergner
@ 2017-03-30 16:21     ` Peter Bergner
  2017-04-02  7:21       ` Andreas Schwab
  2017-04-02  7:29       ` Andreas Schwab
  2017-03-30 17:45     ` Segher Boessenkool
  1 sibling, 2 replies; 17+ messages in thread
From: Peter Bergner @ 2017-03-30 16:21 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches, David Edelsohn, Bill Schmidt

On 3/29/17 6:29 PM, Peter Bergner wrote:
> On 3/29/17 5:28 PM, Segher Boessenkool wrote:

>>> +/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
>>> +/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
>>> +/* { dg-require-effective-target dfp } */
>>
>> You can leave off the default arguments "*" "".  Do we really need to
>> explicitly skip on Darwin and SPE if there is a test for DFP anyway?

Ok, I removed the darwin and spe tests, since the dfp requirement will
disallow those.  I made the same change to teh dfp-builtin-1.c test case
as well.  I also failed to realize that dfp-builtin-1.c was failing due
to the check for no "stfd" and "lfd", which we will now expect to see,
since we're compiling the test case with -mcpu=power7, therefore I
updated the test case to expect them.


>>> +/* { dg-final { scan-assembler-not "drintn\\." } } */
>>> +/* { dg-final { scan-assembler-not "drintnq\\." } } */
>>> +/* { dg-final { scan-assembler-not "dctfix" } } */
>>> +/* { dg-final { scan-assembler-not "dctfixq" } } */
>>
>> If there is no "dctfix" there surely is no "dctfixq" either (i.e., your
>> regexen aren't very tight).
> 
> Ahh, true.  I suppose I could also just look for "drintn" too,
> since that would catch both drintn. and drintnq., ok with that
> change?

Fixed.  Here is an updated patch.  Is this better?

Peter


gcc/
	PR target/80246
	* config/rs6000/dfp.md (dfp_dxex_<mode>): Update mode of operand 0.
	(dfp_diex_<mode>): Update mode of operand 1.
	* doc/extend.texi (dxex, dxexq): Document change to return type.
	(diex, diexq): Document change to argument type.

gcc/testsuite/
	PR target/80246
	* gcc.target/powerpc/dfp-builtin-1.c (dxex, dxexq): Update return types.
	(diex, diexq): Update argument type.
	* gcc.target/powerpc/pr80246.c: New test.


Index: gcc/config/rs6000/dfp.md
===================================================================
--- gcc/config/rs6000/dfp.md	(revision 246539)
+++ gcc/config/rs6000/dfp.md	(working copy)
@@ -348,9 +348,9 @@
   [(set_attr "type" "dfp")])
 
 (define_insn "dfp_dxex_<mode>"
-  [(set (match_operand:D64_D128 0 "gpc_reg_operand" "=d")
-	(unspec:D64_D128 [(match_operand:D64_D128 1 "gpc_reg_operand" "d")]
-			 UNSPEC_DXEX))]
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
+	(unspec:DI [(match_operand:D64_D128 1 "gpc_reg_operand" "d")]
+		   UNSPEC_DXEX))]
   "TARGET_DFP"
   "dxex<dfp_suffix> %0,%1"
   [(set_attr "type" "dfp")])
@@ -357,7 +357,7 @@
 
 (define_insn "dfp_diex_<mode>"
   [(set (match_operand:D64_D128 0 "gpc_reg_operand" "=d")
-	(unspec:D64_D128 [(match_operand:D64_D128 1 "gpc_reg_operand" "d")
+	(unspec:D64_D128 [(match_operand:DI 1 "gpc_reg_operand" "d")
 			  (match_operand:D64_D128 2 "gpc_reg_operand" "d")]
 			 UNSPEC_DXEX))]
   "TARGET_DFP"
Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi	(revision 246539)
+++ gcc/doc/extend.texi	(working copy)
@@ -15427,14 +15427,14 @@
 of processors when hardware decimal floating point
 (@option{-mhard-dfp}) is available:
 @smallexample
-_Decimal64 __builtin_dxex (_Decimal64);
-_Decimal128 __builtin_dxexq (_Decimal128);
+long long __builtin_dxex (_Decimal64);
+long long __builtin_dxexq (_Decimal128);
 _Decimal64 __builtin_ddedpd (int, _Decimal64);
 _Decimal128 __builtin_ddedpdq (int, _Decimal128);
 _Decimal64 __builtin_denbcd (int, _Decimal64);
 _Decimal128 __builtin_denbcdq (int, _Decimal128);
-_Decimal64 __builtin_diex (_Decimal64, _Decimal64);
-_Decimal128 _builtin_diexq (_Decimal128, _Decimal128);
+_Decimal64 __builtin_diex (long long, _Decimal64);
+_Decimal128 _builtin_diexq (long long, _Decimal128);
 _Decimal64 __builtin_dscli (_Decimal64, int);
 _Decimal128 __builtin_dscliq (_Decimal128, int);
 _Decimal64 __builtin_dscri (_Decimal64, int);
Index: gcc/testsuite/gcc.target/powerpc/dfp-builtin-1.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/dfp-builtin-1.c	(revision 246539)
+++ gcc/testsuite/gcc.target/powerpc/dfp-builtin-1.c	(working copy)
@@ -1,6 +1,4 @@
 /* { dg-do compile { target { powerpc*-*-linux* } } } */
-/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
-/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 /* { dg-require-effective-target powerpc_vsx_ok } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
 /* { dg-options "-mcpu=power7 -O2" } */
@@ -10,11 +8,13 @@
 /* { dg-final { scan-assembler-times "diex "   1    } } */
 /* { dg-final { scan-assembler-times "dscli "  2    } } */
 /* { dg-final { scan-assembler-times "dscri "  2    } } */
+/* { dg-final { scan-assembler-times "std "    1    } } */
+/* { dg-final { scan-assembler-times "ld "     1    } } */
+/* { dg-final { scan-assembler-times "stfd "   1    } } */
+/* { dg-final { scan-assembler-times "lfd "    1    } } */
 /* { dg-final { scan-assembler-not   "bl __builtin" } } */
 /* { dg-final { scan-assembler-not   "dctqpq"       } } */
 /* { dg-final { scan-assembler-not   "drdpq"        } } */
-/* { dg-final { scan-assembler-not   "stfd"         } } */
-/* { dg-final { scan-assembler-not   "lfd"          } } */
 
 _Decimal64
 do_dedpd_0 (_Decimal64 a)
@@ -52,7 +52,7 @@
   return __builtin_denbcd (1, a);
 }
 
-_Decimal64
+long long
 do_xex (_Decimal64 a)
 {
   return __builtin_dxex (a);
@@ -59,7 +59,7 @@
 }
 
 _Decimal64
-do_iex (_Decimal64 a, _Decimal64 b)
+do_iex (long long a, _Decimal64 b)
 {
   return __builtin_diex (a, b);
 }
Index: gcc/testsuite/gcc.target/powerpc/pr80246.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr80246.c	(nonexistent)
+++ gcc/testsuite/gcc.target/powerpc/pr80246.c	(working copy)
@@ -0,0 +1,35 @@
+/* { dg-do compile { target { powerpc*-*-linux* } } } */
+/* { dg-require-effective-target dfp } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-times "dxex "  1 } } */
+/* { dg-final { scan-assembler-times "dxexq " 1 } } */
+/* { dg-final { scan-assembler-times "diex "  1 } } */
+/* { dg-final { scan-assembler-times "diexq " 1 } } */
+/* { dg-final { scan-assembler-not "bl __builtin" } } */
+/* { dg-final { scan-assembler-not "drintn" } } */
+/* { dg-final { scan-assembler-not "dctfix" } } */
+/* { dg-final { scan-assembler-not "dcffix" } } */
+
+long long
+do_xex (_Decimal64 arg)
+{
+  return __builtin_dxex (arg);
+}
+
+long long
+do_xexq (_Decimal128 arg)
+{
+  return __builtin_dxexq (arg);
+}
+
+_Decimal64
+do_iex (long long exp, _Decimal64 arg)
+{
+  return __builtin_diex (exp, arg);
+}
+
+_Decimal128
+do_iexq (long long exp, _Decimal128 arg)
+{
+  return __builtin_diexq (exp, arg);
+}


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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-03-30  7:33   ` Peter Bergner
  2017-03-30 16:21     ` Peter Bergner
@ 2017-03-30 17:45     ` Segher Boessenkool
  2017-03-30 18:27       ` Peter Bergner
  1 sibling, 1 reply; 17+ messages in thread
From: Segher Boessenkool @ 2017-03-30 17:45 UTC (permalink / raw)
  To: Peter Bergner; +Cc: GCC Patches, David Edelsohn, Bill Schmidt

> >> +/* { dg-final { scan-assembler-not "drintn\\." } } */
> >> +/* { dg-final { scan-assembler-not "drintnq\\." } } */
> >> +/* { dg-final { scan-assembler-not "dctfix" } } */
> >> +/* { dg-final { scan-assembler-not "dctfixq" } } */
> > 
> > If there is no "dctfix" there surely is no "dctfixq" either (i.e., your
> > regexen aren't very tight).
> 
> Ahh, true.  I suppose I could also just look for "drintn" too,
> since that would catch both drintn. and drintnq., ok with that
> change?

Please add a comment what instructions each regex is supposed to match, then?
Okay with such a change.


Segher

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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-03-30 17:45     ` Segher Boessenkool
@ 2017-03-30 18:27       ` Peter Bergner
  2017-03-30 20:24         ` Peter Bergner
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Bergner @ 2017-03-30 18:27 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches, David Edelsohn, Bill Schmidt

On 3/30/17 12:15 PM, Segher Boessenkool wrote:
>>>> +/* { dg-final { scan-assembler-not "drintn\\." } } */
>>>> +/* { dg-final { scan-assembler-not "drintnq\\." } } */
>>>> +/* { dg-final { scan-assembler-not "dctfix" } } */
>>>> +/* { dg-final { scan-assembler-not "dctfixq" } } */
>>>
>>> If there is no "dctfix" there surely is no "dctfixq" either (i.e., your
>>> regexen aren't very tight).
>>
>> Ahh, true.  I suppose I could also just look for "drintn" too,
>> since that would catch both drintn. and drintnq., ok with that
>> change?
> 
> Please add a comment what instructions each regex is supposed to match, then?
> Okay with such a change.

Actually, the following is probably better.  I'll go with this unless
you object.

 /* { dg-final { scan-assembler-not "drintn\[q\]\." } } */
 /* { dg-final { scan-assembler-not "dctfix\[q\]" } } */
 /* { dg-final { scan-assembler-not "dcffix\[q\]" } } */

Peter


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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-03-30 18:27       ` Peter Bergner
@ 2017-03-30 20:24         ` Peter Bergner
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Bergner @ 2017-03-30 20:24 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: GCC Patches, David Edelsohn, Bill Schmidt

On 3/30/17 12:54 PM, Peter Bergner wrote:
> On 3/30/17 12:15 PM, Segher Boessenkool wrote:
>>>>> +/* { dg-final { scan-assembler-not "drintn\\." } } */
>>>>> +/* { dg-final { scan-assembler-not "drintnq\\." } } */
>>>>> +/* { dg-final { scan-assembler-not "dctfix" } } */
>>>>> +/* { dg-final { scan-assembler-not "dctfixq" } } */
>>>>
>>>> If there is no "dctfix" there surely is no "dctfixq" either (i.e., your
>>>> regexen aren't very tight).
>>>
>>> Ahh, true.  I suppose I could also just look for "drintn" too,
>>> since that would catch both drintn. and drintnq., ok with that
>>> change?
>>
>> Please add a comment what instructions each regex is supposed to match, then?
>> Okay with such a change.
> 
> Actually, the following is probably better.  I'll go with this unless
> you object.
> 
>  /* { dg-final { scan-assembler-not "drintn\[q\]\." } } */
>  /* { dg-final { scan-assembler-not "dctfix\[q\]" } } */
>  /* { dg-final { scan-assembler-not "dcffix\[q\]" } } */

Ok, committed the above change to trunk and GCC 6 and GCC5 release
branches, along with a comment like you wanted.  Thanks.

Peter


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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-03-30 16:21     ` Peter Bergner
@ 2017-04-02  7:21       ` Andreas Schwab
  2017-04-02  7:29       ` Andreas Schwab
  1 sibling, 0 replies; 17+ messages in thread
From: Andreas Schwab @ 2017-04-02  7:21 UTC (permalink / raw)
  To: Peter Bergner
  Cc: Segher Boessenkool, GCC Patches, David Edelsohn, Bill Schmidt

On Mär 30 2017, Peter Bergner <bergner@vnet.ibm.com> wrote:

> Index: gcc/testsuite/gcc.target/powerpc/dfp-builtin-1.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/dfp-builtin-1.c	(revision 246539)
> +++ gcc/testsuite/gcc.target/powerpc/dfp-builtin-1.c	(working copy)
> @@ -1,6 +1,4 @@
>  /* { dg-do compile { target { powerpc*-*-linux* } } } */
> -/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
> -/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
>  /* { dg-require-effective-target powerpc_vsx_ok } */
>  /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
>  /* { dg-options "-mcpu=power7 -O2" } */
> @@ -10,11 +8,13 @@
>  /* { dg-final { scan-assembler-times "diex "   1    } } */
>  /* { dg-final { scan-assembler-times "dscli "  2    } } */
>  /* { dg-final { scan-assembler-times "dscri "  2    } } */
> +/* { dg-final { scan-assembler-times "std "    1    } } */
> +/* { dg-final { scan-assembler-times "ld "     1    } } */

Fails with -m32.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-03-30 16:21     ` Peter Bergner
  2017-04-02  7:21       ` Andreas Schwab
@ 2017-04-02  7:29       ` Andreas Schwab
  2017-04-02 14:48         ` Peter Bergner
  1 sibling, 1 reply; 17+ messages in thread
From: Andreas Schwab @ 2017-04-02  7:29 UTC (permalink / raw)
  To: Peter Bergner
  Cc: Segher Boessenkool, GCC Patches, David Edelsohn, Bill Schmidt

On Mär 30 2017, Peter Bergner <bergner@vnet.ibm.com> wrote:

> Index: gcc/testsuite/gcc.target/powerpc/pr80246.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr80246.c	(nonexistent)
> +++ gcc/testsuite/gcc.target/powerpc/pr80246.c	(working copy)
> @@ -0,0 +1,35 @@
> +/* { dg-do compile { target { powerpc*-*-linux* } } } */
> +/* { dg-require-effective-target dfp } */
> +/* { dg-options "-O2" } */
> +/* { dg-final { scan-assembler-times "dxex "  1 } } */
> +/* { dg-final { scan-assembler-times "dxexq " 1 } } */
> +/* { dg-final { scan-assembler-times "diex "  1 } } */
> +/* { dg-final { scan-assembler-times "diexq " 1 } } */
> +/* { dg-final { scan-assembler-not "bl __builtin" } } */
> +/* { dg-final { scan-assembler-not "drintn" } } */
> +/* { dg-final { scan-assembler-not "dctfix" } } */
> +/* { dg-final { scan-assembler-not "dcffix" } } */
> +
> +long long
> +do_xex (_Decimal64 arg)
> +{
> +  return __builtin_dxex (arg);
> +}
> +
> +long long
> +do_xexq (_Decimal128 arg)
> +{
> +  return __builtin_dxexq (arg);
> +}
> +
> +_Decimal64
> +do_iex (long long exp, _Decimal64 arg)
> +{
> +  return __builtin_diex (exp, arg);
> +}
> +
> +_Decimal128
> +do_iexq (long long exp, _Decimal128 arg)
> +{
> +  return __builtin_diexq (exp, arg);
> +}

FAIL: gcc.target/powerpc/pr80246.c (test for excess errors)
Excess errors:
/daten/gcc/gcc-20170401/gcc/testsuite/gcc.target/powerpc/pr80246.c:18:10: error: Builtin function __builtin_dxex requires the -mhard-dfp option
/daten/gcc/gcc-20170401/gcc/testsuite/gcc.target/powerpc/pr80246.c:24:10: error: Builtin function __builtin_dxexq requires the -mhard-dfp option
/daten/gcc/gcc-20170401/gcc/testsuite/gcc.target/powerpc/pr80246.c:30:10: error: Builtin function __builtin_diex requires the -mhard-dfp option
/daten/gcc/gcc-20170401/gcc/testsuite/gcc.target/powerpc/pr80246.c:36:10: error: Builtin function __builtin_diexq requires the -mhard-dfp option

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-04-02  7:29       ` Andreas Schwab
@ 2017-04-02 14:48         ` Peter Bergner
  2017-04-02 15:07           ` Andreas Schwab
  2017-04-02 18:54           ` Segher Boessenkool
  0 siblings, 2 replies; 17+ messages in thread
From: Peter Bergner @ 2017-04-02 14:48 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Segher Boessenkool, GCC Patches, David Edelsohn, Bill Schmidt

On 4/2/17 2:29 AM, Andreas Schwab wrote:
>> +/* { dg-require-effective-target dfp } */
[snip]
> FAIL: gcc.target/powerpc/pr80246.c (test for excess errors)
> Excess errors:
> /daten/gcc/gcc-20170401/gcc/testsuite/gcc.target/powerpc/pr80246.c:18:10:
>  error: Builtin function __builtin_dxex requires the -mhard-dfp option

What configure options are you using?  I would have expected this the
dg-require-effective-target to disable this test if you don't have
-mhard-dfp.

Peter



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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-04-02 14:48         ` Peter Bergner
@ 2017-04-02 15:07           ` Andreas Schwab
  2017-04-02 18:54           ` Segher Boessenkool
  1 sibling, 0 replies; 17+ messages in thread
From: Andreas Schwab @ 2017-04-02 15:07 UTC (permalink / raw)
  To: Peter Bergner
  Cc: Segher Boessenkool, GCC Patches, David Edelsohn, Bill Schmidt

On Apr 02 2017, Peter Bergner <bergner@vnet.ibm.com> wrote:

> On 4/2/17 2:29 AM, Andreas Schwab wrote:
>>> +/* { dg-require-effective-target dfp } */
> [snip]
>> FAIL: gcc.target/powerpc/pr80246.c (test for excess errors)
>> Excess errors:
>> /daten/gcc/gcc-20170401/gcc/testsuite/gcc.target/powerpc/pr80246.c:18:10:
>>  error: Builtin function __builtin_dxex requires the -mhard-dfp option
>
> What configure options are you using?

http://gcc.gnu.org/ml/gcc-testresults/2017-04/msg00126.html

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-04-02 14:48         ` Peter Bergner
  2017-04-02 15:07           ` Andreas Schwab
@ 2017-04-02 18:54           ` Segher Boessenkool
  2017-04-03 14:41             ` Peter Bergner
  2017-04-03 16:04             ` Peter Bergner
  1 sibling, 2 replies; 17+ messages in thread
From: Segher Boessenkool @ 2017-04-02 18:54 UTC (permalink / raw)
  To: Peter Bergner; +Cc: Andreas Schwab, GCC Patches, David Edelsohn, Bill Schmidt

On Sun, Apr 02, 2017 at 09:48:36AM -0500, Peter Bergner wrote:
> On 4/2/17 2:29 AM, Andreas Schwab wrote:
> >> +/* { dg-require-effective-target dfp } */
> [snip]
> > FAIL: gcc.target/powerpc/pr80246.c (test for excess errors)
> > Excess errors:
> > /daten/gcc/gcc-20170401/gcc/testsuite/gcc.target/powerpc/pr80246.c:18:10:
> >  error: Builtin function __builtin_dxex requires the -mhard-dfp option
> 
> What configure options are you using?  I would have expected this the
> dg-require-effective-target to disable this test if you don't have
> -mhard-dfp.

This should test hard_dfp instead of dfp.  I also have a fix for the
dfp-builtin-1.c problem.  Still pondering what to do about the last one,
fold-vec-mule-misc.c: vsx_ok is pretty useless, or confusingly named at
least.


Segher

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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-04-02 18:54           ` Segher Boessenkool
@ 2017-04-03 14:41             ` Peter Bergner
  2017-04-03 14:55               ` Peter Bergner
  2017-04-03 16:04             ` Peter Bergner
  1 sibling, 1 reply; 17+ messages in thread
From: Peter Bergner @ 2017-04-03 14:41 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Andreas Schwab, GCC Patches, David Edelsohn, Bill Schmidt

On 4/2/17 1:53 PM, Segher Boessenkool wrote:
> On Sun, Apr 02, 2017 at 09:48:36AM -0500, Peter Bergner wrote:
>> On 4/2/17 2:29 AM, Andreas Schwab wrote:
>>>> +/* { dg-require-effective-target dfp } */
>> [snip]
>>> FAIL: gcc.target/powerpc/pr80246.c (test for excess errors)
>>> Excess errors:
>>> /daten/gcc/gcc-20170401/gcc/testsuite/gcc.target/powerpc/pr80246.c:18:10:
>>>  error: Builtin function __builtin_dxex requires the -mhard-dfp option
>>
>> What configure options are you using?  I would have expected this the
>> dg-require-effective-target to disable this test if you don't have
>> -mhard-dfp.
> 
> This should test hard_dfp instead of dfp.  

Ah, yes, dfp is just support for they DFP types.  I'll make that
change and commit it.



> I also have a fix for the dfp-builtin-1.c problem.

You mean you have a patch to the regex to match both std/stw and ld/lwz?



> Still pondering what to do about the last one, fold-vec-mule-misc.c:
> vsx_ok is pretty useless, or confusingly named at least.

Ummm, how would my patch have affected that FAIL, as it doesn't use
any _Decimal* types, let alone the dxex* or diex* patterns that I
changed?

Peter

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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-04-03 14:41             ` Peter Bergner
@ 2017-04-03 14:55               ` Peter Bergner
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Bergner @ 2017-04-03 14:55 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Andreas Schwab, GCC Patches, David Edelsohn, Bill Schmidt

On 4/3/17 9:41 AM, Peter Bergner wrote:
> On 4/2/17 1:53 PM, Segher Boessenkool wrote:
>> I also have a fix for the dfp-builtin-1.c problem.
> 
> You mean you have a patch to the regex to match both std/stw and ld/lwz?

I think we should also add:

  /* { dg-require-effective-target hard_dfp } */

to the dfp-builtin-1.c requirements, since I think someone could do
-mno-hard-dfp while also having VSX enabled.  Ditto for dfp-builtin-2.c.

Peter

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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-04-02 18:54           ` Segher Boessenkool
  2017-04-03 14:41             ` Peter Bergner
@ 2017-04-03 16:04             ` Peter Bergner
  2017-04-03 17:01               ` Peter Bergner
  1 sibling, 1 reply; 17+ messages in thread
From: Peter Bergner @ 2017-04-03 16:04 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Andreas Schwab, GCC Patches, David Edelsohn, Bill Schmidt

On 4/2/17 1:53 PM, Segher Boessenkool wrote:
> I also have a fix for the dfp-builtin-1.c problem.

Something like the following maybe?  It seems to work for me.
I think the hard_dfp predicate was added after the dfp-builtin-[12].c
test cases were added, which is maybe why Mike used powerpc_vsx_ok?
Seems like we should switch it to using hard_dfp now.

Peter


Index: dfp-builtin-1.c
===================================================================
--- dfp-builtin-1.c	(revision 246648)
+++ dfp-builtin-1.c	(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { powerpc*-*-linux* } } } */
-/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-require-effective-target hard_dfp } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
 /* { dg-options "-mcpu=power7 -O2" } */
 /* { dg-final { scan-assembler-times "ddedpd " 4    } } */
@@ -8,8 +8,10 @@
 /* { dg-final { scan-assembler-times "diex "   1    } } */
 /* { dg-final { scan-assembler-times "dscli "  2    } } */
 /* { dg-final { scan-assembler-times "dscri "  2    } } */
-/* { dg-final { scan-assembler-times "std "    1    } } */
-/* { dg-final { scan-assembler-times "ld "     1    } } */
+/* { dg-final { scan-assembler-times "std "    1    { target lp64 } } } */
+/* { dg-final { scan-assembler-times "ld "     1    { target lp64 } } } */
+/* { dg-final { scan-assembler-times "stw "    2    { target ilp32 } } } */
+/* { dg-final { scan-assembler-times "lwz "    2    { target ilp32 } } } */
 /* { dg-final { scan-assembler-times "stfd "   1    } } */
 /* { dg-final { scan-assembler-times "lfd "    1    } } */
 /* { dg-final { scan-assembler-not   "bl __builtin" } } */
Index: dfp-builtin-2.c
===================================================================
--- dfp-builtin-2.c	(revision 246648)
+++ dfp-builtin-2.c	(working copy)
@@ -1,7 +1,6 @@
 /* { dg-do compile { target { powerpc*-*-linux* } } } */
-/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
-/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 /* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-require-effective-target hard_dfp } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
 /* { dg-options "-mcpu=power7 -O2" } */
 /* { dg-final { scan-assembler-times "ddedpdq " 4    } } */


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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-04-03 16:04             ` Peter Bergner
@ 2017-04-03 17:01               ` Peter Bergner
  2017-04-03 18:08                 ` Peter Bergner
  0 siblings, 1 reply; 17+ messages in thread
From: Peter Bergner @ 2017-04-03 17:01 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Andreas Schwab, GCC Patches, David Edelsohn, Bill Schmidt

On 4/3/17 11:04 AM, Peter Bergner wrote:
> On 4/2/17 1:53 PM, Segher Boessenkool wrote:
>> I also have a fix for the dfp-builtin-1.c problem.
> 
> Something like the following maybe?  It seems to work for me.
> I think the hard_dfp predicate was added after the dfp-builtin-[12].c
> test cases were added, which is maybe why Mike used powerpc_vsx_ok?
> Seems like we should switch it to using hard_dfp now.

As we discussed offline, I'll commit the following patch to fix up
the dfp-builtin-1.c failures.  I'll also commit this to the GCC 5 & 6
release branches, since the same issue exists there.

Peter


Index: dfp-builtin-1.c
===================================================================
--- dfp-builtin-1.c	(revision 246653)
+++ dfp-builtin-1.c	(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { powerpc*-*-linux* } } } */
-/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-require-effective-target hard_dfp } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
 /* { dg-options "-mcpu=power7 -O2" } */
 /* { dg-final { scan-assembler-times "ddedpd " 4    } } */
@@ -8,8 +8,12 @@
 /* { dg-final { scan-assembler-times "diex "   1    } } */
 /* { dg-final { scan-assembler-times "dscli "  2    } } */
 /* { dg-final { scan-assembler-times "dscri "  2    } } */
-/* { dg-final { scan-assembler-times "std "    1    } } */
-/* { dg-final { scan-assembler-times "ld "     1    } } */
+/* { dg-final { scan-assembler-times "std "    1    { target lp64 } } } */
+/* { dg-final { scan-assembler-times "ld "     1    { target lp64 } } } */
+/* 32-bit needs a stack frame, and needs two GPR mem insns per _Decimal64.  */
+/* { dg-final { scan-assembler-times "stwu "   2    { target ilp32 } } } */
+/* { dg-final { scan-assembler-times "stw "    2    { target ilp32 } } } */
+/* { dg-final { scan-assembler-times "lwz "    2    { target ilp32 } } } */
 /* { dg-final { scan-assembler-times "stfd "   1    } } */
 /* { dg-final { scan-assembler-times "lfd "    1    } } */
 /* { dg-final { scan-assembler-not   "bl __builtin" } } */
Index: dfp-builtin-2.c
===================================================================
--- dfp-builtin-2.c	(revision 246653)
+++ dfp-builtin-2.c	(working copy)
@@ -1,7 +1,5 @@
 /* { dg-do compile { target { powerpc*-*-linux* } } } */
-/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
-/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
-/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-require-effective-target hard_dfp } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
 /* { dg-options "-mcpu=power7 -O2" } */
 /* { dg-final { scan-assembler-times "ddedpdq " 4    } } */


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

* Re: [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types
  2017-04-03 17:01               ` Peter Bergner
@ 2017-04-03 18:08                 ` Peter Bergner
  0 siblings, 0 replies; 17+ messages in thread
From: Peter Bergner @ 2017-04-03 18:08 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Andreas Schwab, GCC Patches, David Edelsohn, Bill Schmidt

On 4/3/17 12:01 PM, Peter Bergner wrote:
> On 4/3/17 11:04 AM, Peter Bergner wrote:
>> On 4/2/17 1:53 PM, Segher Boessenkool wrote:
>>> I also have a fix for the dfp-builtin-1.c problem.
>>
>> Something like the following maybe?  It seems to work for me.
>> I think the hard_dfp predicate was added after the dfp-builtin-[12].c
>> test cases were added, which is maybe why Mike used powerpc_vsx_ok?
>> Seems like we should switch it to using hard_dfp now.
> 
> As we discussed offline, I'll commit the following patch to fix up
> the dfp-builtin-1.c failures.  I'll also commit this to the GCC 5 & 6
> release branches, since the same issue exists there.

Ok, committed everywhere.  Thanks and sorry about the breakage! :-(

Peter


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

end of thread, other threads:[~2017-04-03 18:08 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-29 21:20 [PATCH, rs6000] Fix PR target/80246, DFP builtins using the wrong types Peter Bergner
2017-03-29 22:36 ` Segher Boessenkool
2017-03-30  7:33   ` Peter Bergner
2017-03-30 16:21     ` Peter Bergner
2017-04-02  7:21       ` Andreas Schwab
2017-04-02  7:29       ` Andreas Schwab
2017-04-02 14:48         ` Peter Bergner
2017-04-02 15:07           ` Andreas Schwab
2017-04-02 18:54           ` Segher Boessenkool
2017-04-03 14:41             ` Peter Bergner
2017-04-03 14:55               ` Peter Bergner
2017-04-03 16:04             ` Peter Bergner
2017-04-03 17:01               ` Peter Bergner
2017-04-03 18:08                 ` Peter Bergner
2017-03-30 17:45     ` Segher Boessenkool
2017-03-30 18:27       ` Peter Bergner
2017-03-30 20:24         ` Peter Bergner

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).