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: PATCH: PR target/53416: Wrong code when optimising loop involving _rdrand32_step


On Sun, May 20, 2012 at 12:03 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Sun, May 20, 2012 at 8:43 PM, Andrew Pinski <pinskia@gmail.com> wrote:
>
>> #include <stdio.h>
>>
>> ?int
>> ?main(int argc, char **argv)
>> ?{
>> ?unsigned int number = 0;
>> ?int result0, result1, result2, result3;
>>
>> ?result0 = __builtin_ia32_rdrand32_step (&number);
>> ?result1 = __builtin_ia32_rdrand32_step (&number);
>> ?result2 = __builtin_ia32_rdrand32_step (&number);
>> ?result3 = __builtin_ia32_rdrand32_step (&number);
>> ?printf("%d: %d\n", result0, number);
>> ?printf("%d: %d\n", result1, number);
>> ?printf("%d: %d\n", result2, number);
>> ?printf("%d: %d\n", result3, number);
>> ?return 0;
>> ?}
>>
>
> int test (void)
> {
> ?unsigned int number = 0;
> ?int result0, result1, result2, result3;
>
> ?result0 = __builtin_ia32_rdrand32_step (&number);
> ?result1 = __builtin_ia32_rdrand32_step (&number);
> ?result2 = __builtin_ia32_rdrand32_step (&number);
> ?result3 = __builtin_ia32_rdrand32_step (&number);
>
> ?return result0 + result1 +result2 + result3;;
> }
>
> This is the simplest, and also good test.
>

Is this patck OK for trunk, 4.7 and 4.6?

Thanks.


-- 
H.J.
---
gcc/

2012-05-20  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/53416
	* config/i386/i386.md (UNSPEC_RDRAND): Renamed to ...
	(UNSPECV_RDRAND): This.
	(rdrand<mode>_1): Updated.

gcc/testsuite/

2012-05-20  Uros Bizjak  <ubizjak@gmail.com>
	    H.J. Lu  <hongjiu.lu@intel.com>

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index cce78b5..9327acf 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -176,9 +176,6 @@
   ;; For CRC32 support
   UNSPEC_CRC32

-  ;; For RDRAND support
-  UNSPEC_RDRAND
-
   ;; For BMI support
   UNSPEC_BEXTR

@@ -208,6 +205,9 @@
   UNSPECV_WRFSBASE
   UNSPECV_WRGSBASE

+  ;; For RDRAND support
+  UNSPECV_RDRAND
+
   ;; For RTM support
   UNSPECV_XBEGIN
   UNSPECV_XEND
@@ -18399,9 +18399,9 @@

 (define_insn "rdrand<mode>_1"
   [(set (match_operand:SWI248 0 "register_operand" "=r")
-	(unspec:SWI248 [(const_int 0)] UNSPEC_RDRAND))
+	(unspec_volatile:SWI248 [(const_int 0)] UNSPECV_RDRAND))
    (set (reg:CCC FLAGS_REG)
-	(unspec:CCC [(const_int 0)] UNSPEC_RDRAND))]
+	(unspec_volatile:CCC [(const_int 0)] UNSPECV_RDRAND))]
   "TARGET_RDRND"
   "rdrand\t%0"
   [(set_attr "type" "other")
diff --git a/gcc/testsuite/gcc.target/i386/pr53416.c
b/gcc/testsuite/gcc.target/i386/pr53416.c
new file mode 100644
index 0000000..d0a159b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr53416.c
@@ -0,0 +1,17 @@
+/* PR target/53416 */
+/* { dg-options "-O2 -mrdrnd" } */
+
+int test (void)
+{
+  unsigned int number = 0;
+  int result0, result1, result2, result3;
+
+  result0 = __builtin_ia32_rdrand32_step (&number);
+  result1 = __builtin_ia32_rdrand32_step (&number);
+  result2 = __builtin_ia32_rdrand32_step (&number);
+  result3 = __builtin_ia32_rdrand32_step (&number);
+
+  return result0 + result1 +result2 + result3;;
+}
+
+/* { dg-final { scan-assembler-times "rdrand" 4 } } */


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