This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: PR target/46085: [4..6 Regression] gcc.dg/vect/fast-math-vect-reduc-[57].c failed with -mavx -ffast-math -O3
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Oct 2010 15:13:19 -0700
- Subject: PATCH: PR target/46085: [4..6 Regression] gcc.dg/vect/fast-math-vect-reduc-[57].c failed with -mavx -ffast-math -O3
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
This patch fixes reduc_splus_v8sf and reduc_splus_v4df. Tested on
Linux/Intel64 with AVX. OK for trunk?
Thanks.
H.J.
---
gcc/
2010-10-19 H.J. Lu <hongjiu.lu@intel.com>
PR target/46085
* config/i386/sse.md (reduc_splus_v8sf): Updated.
(reduc_splus_v4df): Likewise.
gcc/
2010-10-19 H.J. Lu <hongjiu.lu@intel.com>
PR target/46085
* gcc.target/i386/pr46085-1.c: New.
* gcc.target/i386/pr46085-2.c: Likewise.
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index e5e2465..3a49361 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -1387,8 +1387,9 @@
rtx tmp = gen_reg_rtx (V8SFmode);
rtx tmp2 = gen_reg_rtx (V8SFmode);
emit_insn (gen_avx_haddv8sf3 (tmp, operands[1], operands[1]));
- emit_insn (gen_avx_haddv8sf3 (tmp2, operands[1], operands[1]));
- emit_insn (gen_avx_haddv8sf3 (operands[0], tmp2, tmp2));
+ emit_insn (gen_avx_haddv8sf3 (tmp2, tmp, tmp));
+ emit_insn (gen_avx_vperm2f128v8sf3 (tmp, tmp2, tmp2, GEN_INT (1)));
+ emit_insn (gen_addv8sf3 (operands[0], tmp, tmp2));
DONE;
})
@@ -1414,8 +1415,10 @@
"TARGET_AVX"
{
rtx tmp = gen_reg_rtx (V4DFmode);
+ rtx tmp2 = gen_reg_rtx (V4DFmode);
emit_insn (gen_avx_haddv4df3 (tmp, operands[1], operands[1]));
- emit_insn (gen_avx_haddv4df3 (operands[0], tmp, tmp));
+ emit_insn (gen_avx_vperm2f128v4df3 (tmp2, tmp, tmp, GEN_INT (1)));
+ emit_insn (gen_addv4df3 (operands[0], tmp, tmp2));
DONE;
})
--- /dev/null 2010-10-18 14:05:31.203270943 -0700
+++ gcc-avx/gcc/testsuite/gcc.target/i386/pr46085-1.c 2010-10-19 15:06:23.645985752 -0700
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx } */
+/* { dg-options "-O2 -ftree-vectorize -mavx -mtune=generic -ffast-math" } */
+
+#include "avx-check.h"
+
+#define N 16
+#define DIFF 242
+
+float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
+float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+void
+main1 (float x, float max_result)
+{
+ int i;
+ float diff = 2;
+ float max = x;
+ float min = 10;
+
+ for (i = 0; i < N; i++) {
+ diff += (b[i] - c[i]);
+ }
+
+ for (i = 0; i < N; i++) {
+ max = max < c[i] ? c[i] : max;
+ }
+
+ for (i = 0; i < N; i++) {
+ min = min > c[i] ? c[i] : min;
+ }
+
+ /* check results: */
+ if (diff != DIFF)
+ abort ();
+ if (max != max_result)
+ abort ();
+ if (min != 0)
+ abort ();
+}
+
+static void
+avx_test (void)
+{
+ main1 (100, 100);
+ main1 (0, 15);
+}
--- /dev/null 2010-10-18 14:05:31.203270943 -0700
+++ gcc-avx/gcc/testsuite/gcc.target/i386/pr46085-2.c 2010-10-19 15:07:08.157964873 -0700
@@ -0,0 +1,47 @@
+/* { dg-do run } */
+/* { dg-require-effective-target avx } */
+/* { dg-options "-O2 -ftree-vectorize -mavx -mtune=generic -ffast-math" } */
+
+#include "avx-check.h"
+
+#define N 16
+#define DIFF 242
+
+double b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
+double c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+void
+main1 (double x, double max_result)
+{
+ int i;
+ double diff = 2;
+ double max = x;
+ double min = 10;
+
+ for (i = 0; i < N; i++) {
+ diff += (b[i] - c[i]);
+ }
+
+ for (i = 0; i < N; i++) {
+ max = max < c[i] ? c[i] : max;
+ }
+
+ for (i = 0; i < N; i++) {
+ min = min > c[i] ? c[i] : min;
+ }
+
+ /* check results: */
+ if (diff != DIFF)
+ abort ();
+ if (max != max_result)
+ abort ();
+ if (min != 0)
+ abort ();
+}
+
+static void
+avx_test (void)
+{
+ main1 (100, 100);
+ main1 (0, 15);
+}