aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2018-05-10 22:59:18 +0200
committerUros Bizjak <uros@gcc.gnu.org>2018-05-10 22:59:18 +0200
commit1c3c479a04317df136f439a90ab5c47e21bfd7f8 (patch)
tree2e21b265c8d2ad9ec5674593d3051b55f1753951
parent267eee04fe4a0f18189f0ab620303656ba316ea7 (diff)
downloadgcc-1c3c479a04317df136f439a90ab5c47e21bfd7f8.zip
gcc-1c3c479a04317df136f439a90ab5c47e21bfd7f8.tar.gz
gcc-1c3c479a04317df136f439a90ab5c47e21bfd7f8.tar.bz2
i386.c (ix86_expand_builtin): Generate SImode target register for null target.
* config/i386/i386.c (ix86_expand_builtin) <case IX86_BUILTIN_RDPID>: Generate SImode target register for null target. <case IX86_BUILTIN_XGETBV>: Ditto. <case IX86_BUILTIN_XSETBV>: Optimize LSHIFTRT generation. * config/i386/xsaveintrin.h (_xgetbv): Add missing return. testsuite/ChangeLog: * gcc.target/i386/xgetsetbv.c: Check also variable arguments. From-SVN: r260135
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/config/i386/i386.c39
-rw-r--r--gcc/config/i386/xsaveintrin.h2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/i386/xgetsetbv.c22
5 files changed, 46 insertions, 29 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 64ec271..821655a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2018-05-10 Uros Bizjak <ubizjak@gmail.com>
+
+ * config/i386/i386.c (ix86_expand_builtin) <case IX86_BUILTIN_RDPID>:
+ Generate SImode target register for null target.
+ <case IX86_BUILTIN_XGETBV>: Ditto.
+ <case IX86_BUILTIN_XSETBV>: Optimize LSHIFTRT generation.
+ * config/i386/xsaveintrin.h (_xgetbv): Add missing return.
+
2018-05-10 Carl Love <cel@us.ibm.com>
* config/rs6000/rs6000.md (prefetch): Generate ISA 2.06 instructions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 70e87fb..526e7d1 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -37085,7 +37085,7 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
case IX86_BUILTIN_RDPID:
- op0 = gen_reg_rtx (TARGET_64BIT ? DImode : SImode);
+ op0 = gen_reg_rtx (word_mode);
if (TARGET_64BIT)
{
@@ -37094,18 +37094,16 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
}
else
insn = gen_rdpid (op0);
+
emit_insn (insn);
- if (target == 0)
- {
- /* mode is VOIDmode if __builtin_rdpid has been called
- without lhs. */
- if (mode == VOIDmode)
- return target;
- target = gen_reg_rtx (mode);
- }
+ if (target == 0
+ || !register_operand (target, SImode))
+ target = gen_reg_rtx (SImode);
+
emit_move_insn (target, op0);
return target;
+
case IX86_BUILTIN_RDPMC:
case IX86_BUILTIN_RDTSC:
case IX86_BUILTIN_RDTSCP:
@@ -37164,14 +37162,9 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
emit_move_insn (gen_rtx_MEM (SImode, op4), op2);
}
- if (target == 0)
- {
- /* mode is VOIDmode if __builtin_rd* has been called
- without lhs. */
- if (mode == VOIDmode)
- return target;
- target = gen_reg_rtx (mode);
- }
+ if (target == 0
+ || !register_operand (target, DImode))
+ target = gen_reg_rtx (DImode);
if (TARGET_64BIT)
{
@@ -37260,25 +37253,23 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
if (!REG_P (op0))
op0 = copy_to_mode_reg (SImode, op0);
+ op1 = force_reg (DImode, op1);
+
if (TARGET_64BIT)
{
op2 = expand_simple_binop (DImode, LSHIFTRT, op1, GEN_INT (32),
NULL, 1, OPTAB_DIRECT);
+ icode = CODE_FOR_xsetbv_rex64;
+
op2 = gen_lowpart (SImode, op2);
op1 = gen_lowpart (SImode, op1);
- if (!REG_P (op1))
- op1 = copy_to_mode_reg (SImode, op1);
- if (!REG_P (op2))
- op2 = copy_to_mode_reg (SImode, op2);
- icode = CODE_FOR_xsetbv_rex64;
pat = GEN_FCN (icode) (op0, op1, op2);
}
else
{
- if (!REG_P (op1))
- op1 = copy_to_mode_reg (DImode, op1);
icode = CODE_FOR_xsetbv;
+
pat = GEN_FCN (icode) (op0, op1);
}
if (pat)
diff --git a/gcc/config/i386/xsaveintrin.h b/gcc/config/i386/xsaveintrin.h
index 705936e..3f6c80b 100644
--- a/gcc/config/i386/xsaveintrin.h
+++ b/gcc/config/i386/xsaveintrin.h
@@ -59,7 +59,7 @@ extern __inline long long
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
_xgetbv (unsigned int __A)
{
- __builtin_ia32_xgetbv (__A);
+ return __builtin_ia32_xgetbv (__A);
}
#ifdef __x86_64__
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 89f6440..6d90666 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2018-05-10 Uros Bizjak <ubizjak@gmail.com>
+
+ * gcc.target/i386/xgetsetbv.c: Check also variable arguments.
+
2018-05-10 Jakub Jelinek <jakub@redhat.com>
PR c++/85662
diff --git a/gcc/testsuite/gcc.target/i386/xgetsetbv.c b/gcc/testsuite/gcc.target/i386/xgetsetbv.c
index 9a9af1b..9ef487c 100644
--- a/gcc/testsuite/gcc.target/i386/xgetsetbv.c
+++ b/gcc/testsuite/gcc.target/i386/xgetsetbv.c
@@ -1,12 +1,26 @@
/* { dg-do compile } */
/* { dg-options "-O2 -mxsave" } */
-/* { dg-final { scan-assembler "xgetbv" } } */
-/* { dg-final { scan-assembler "xsetbv" } } */
+/* { dg-final { scan-assembler-times "xgetbv" 3 } } */
+/* { dg-final { scan-assembler-times "xsetbv" 3 } } */
#include <x86intrin.h>
-unsigned int
-xgetsetbv (void)
+unsigned long long
+foo (unsigned x, unsigned y)
+{
+ _xsetbv (x, y);
+ return _xgetbv (x);
+}
+
+unsigned long long
+bar (unsigned x, unsigned long long y)
+{
+ _xsetbv (x, y);
+ return _xgetbv (x);
+}
+
+unsigned long long
+baz (void)
{
_xsetbv (0, 0);
return _xgetbv (0);