aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2016-05-09 17:37:30 +0200
committerUros Bizjak <uros@gcc.gnu.org>2016-05-09 17:37:30 +0200
commitfc97f8050225946f1f8ba00046ff0d068783c3b4 (patch)
treee08cacca4be27d30ed814de006fa7ceae96ce517
parente3abc83ebaea2312510ace3da69436393e73046c (diff)
downloadgcc-fc97f8050225946f1f8ba00046ff0d068783c3b4.zip
gcc-fc97f8050225946f1f8ba00046ff0d068783c3b4.tar.gz
gcc-fc97f8050225946f1f8ba00046ff0d068783c3b4.tar.bz2
i386.md (absneg splitters with general regs): Use general_reg_operand predicate.
* config/i386/i386.md (absneg splitters with general regs): Use general_reg_operand predicate. (btsq peephole2): Use x86_64_immediate_operand to check if new value is suitable for immediate operand. Generate emitted insn using RTL expressions. (btcq peephole2): Ditto. (btrq peephole2): Ditto. Generate correct immediate operand for AND masking. testsuite/ChangeLog: * gcc.target/i386/fabsneg-1.c New test. From-SVN: r236042
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/config/i386/i386.md51
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/i386/fabsneg-1.c36
4 files changed, 75 insertions, 27 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 314f5f6..007ae87 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2016-05-09 Uros Bizjak <ubizjak@gmail.com>
+
+ * config/i386/i386.md (absneg splitters with general regs): Use
+ general_reg_operand predicate.
+ (btsq peephole2): Use x86_64_immediate_operand to check if new
+ value is suitable for immediate operand. Generate emitted insn
+ using RTL expressions.
+ (btcq peephole2): Ditto.
+ (btrq peephole2): Ditto. Generate correct immediate operand
+ for AND masking.
+
2016-05-09 Richard Sandiford <richard.sandiford@arm.com>
* cfgexpand.c (expand_debug_expr): Fix address offset for negative
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index f450cf2..9b5407a 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -9306,7 +9306,7 @@
})
(define_split
- [(set (match_operand:SF 0 "register_operand")
+ [(set (match_operand:SF 0 "general_reg_operand")
(match_operator:SF 1 "absneg_operator" [(match_dup 0)]))
(use (match_operand:V4SF 2))
(clobber (reg:CC FLAGS_REG))]
@@ -9330,7 +9330,7 @@
})
(define_split
- [(set (match_operand:DF 0 "register_operand")
+ [(set (match_operand:DF 0 "general_reg_operand")
(match_operator:DF 1 "absneg_operator" [(match_dup 0)]))
(use (match_operand 2))
(clobber (reg:CC FLAGS_REG))]
@@ -9368,7 +9368,7 @@
})
(define_split
- [(set (match_operand:XF 0 "register_operand")
+ [(set (match_operand:XF 0 "general_reg_operand")
(match_operator:XF 1 "absneg_operator" [(match_dup 0)]))
(use (match_operand 2))
(clobber (reg:CC FLAGS_REG))]
@@ -11049,20 +11049,19 @@
(const_int 1))
(clobber (reg:CC FLAGS_REG))])]
"TARGET_64BIT && !TARGET_USE_BT"
- [(const_int 0)]
+ [(parallel [(set (match_dup 0)
+ (ior:DI (match_dup 0) (match_dup 3)))
+ (clobber (reg:CC FLAGS_REG))])]
{
int i = INTVAL (operands[1]);
- rtx op1 = gen_int_mode (HOST_WIDE_INT_1U << i, DImode);
+ operands[3] = gen_int_mode (HOST_WIDE_INT_1U << i, DImode);
- if (i >= 31)
+ if (!x86_64_immediate_operand (operands[3], DImode))
{
- emit_move_insn (operands[2], op1);
- op1 = operands[2];
+ emit_move_insn (operands[2], operands[3]);
+ operands[3] = operands[2];
}
-
- emit_insn (gen_iordi3 (operands[0], operands[0], op1));
- DONE;
})
(define_peephole2
@@ -11074,20 +11073,19 @@
(const_int 0))
(clobber (reg:CC FLAGS_REG))])]
"TARGET_64BIT && !TARGET_USE_BT"
- [(const_int 0)]
+ [(parallel [(set (match_dup 0)
+ (and:DI (match_dup 0) (match_dup 3)))
+ (clobber (reg:CC FLAGS_REG))])]
{
int i = INTVAL (operands[1]);
- rtx op1 = gen_int_mode (HOST_WIDE_INT_1U << i, DImode);
+ operands[3] = gen_int_mode (~(HOST_WIDE_INT_1U << i), DImode);
- if (i >= 32)
+ if (!x86_64_immediate_operand (operands[3], DImode))
{
- emit_move_insn (operands[2], op1);
- op1 = operands[2];
+ emit_move_insn (operands[2], operands[3]);
+ operands[3] = operands[2];
}
-
- emit_insn (gen_anddi3 (operands[0], operands[0], op1));
- DONE;
})
(define_peephole2
@@ -11100,20 +11098,19 @@
(match_dup 0) (const_int 1) (match_dup 1))))
(clobber (reg:CC FLAGS_REG))])]
"TARGET_64BIT && !TARGET_USE_BT"
- [(const_int 0)]
+ [(parallel [(set (match_dup 0)
+ (xor:DI (match_dup 0) (match_dup 3)))
+ (clobber (reg:CC FLAGS_REG))])]
{
int i = INTVAL (operands[1]);
- rtx op1 = gen_int_mode (HOST_WIDE_INT_1U << i, DImode);
+ operands[3] = gen_int_mode (HOST_WIDE_INT_1U << i, DImode);
- if (i >= 31)
+ if (!x86_64_immediate_operand (operands[3], DImode))
{
- emit_move_insn (operands[2], op1);
- op1 = operands[2];
+ emit_move_insn (operands[2], operands[3]);
+ operands[3] = operands[2];
}
-
- emit_insn (gen_xordi3 (operands[0], operands[0], op1));
- DONE;
})
(define_insn "*bt<mode>"
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ebb70e9..29a9709 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-05-09 Uros Bizjak <ubizjak@gmail.com>
+
+ * gcc.target/i386/fabsneg-1.c New test.
+
2016-05-09 Alan Modra <amodra@gmail.com>
PR testsuite/70826
diff --git a/gcc/testsuite/gcc.target/i386/fabsneg-1.c b/gcc/testsuite/gcc.target/i386/fabsneg-1.c
new file mode 100644
index 0000000..3cdf456
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/fabsneg-1.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-O2 -mtune=nocona" } */
+
+double x;
+
+void
+__attribute__ ((noinline, noclone))
+test_fabs (double a)
+{
+ asm volatile ("" : "+r" (a));
+ x = __builtin_fabs (a);
+}
+
+void
+__attribute__ ((noinline, noclone))
+test_neg (double a)
+{
+ asm volatile ("" : "+r" (a));
+ x = -a;
+}
+
+int main ()
+{
+ test_fabs (-1.0);
+
+ if (x != 1.0)
+ __builtin_abort ();
+
+ test_neg (-1.0);
+
+ if (x != 1.0)
+ __builtin_abort ();
+
+ return 0;
+}