This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix middle-end/17767
- From: Uros Bizjak <uros at kss-loka dot si>
- To: gcc-patches at gcc dot gnu dot org, Roger Sayle <roger at eyesopen dot com>
- Date: Tue, 04 Jan 2005 10:18:50 +0100
- Subject: Fix middle-end/17767
Hello!
This patch fixes PR target/17767 (middle-end/17767). fold_rtx () should
handle vector modes, when two equal vectors are compared.
The solution is to compose a false_rtx and true_rtx from
VECTOR_STORE_FLAG_VALUE and return this vector as a result for vector
modes, instead of only scalar const_false_rtx/const_true_rtx. The
VECTOR_STORE_FLAG_VALUE for SSE is known to be 0xFFFF, but I didn't want
to enable this functionality, because lots of bugs could be uncovered
(look at simplify-rtx.c change :)). However, the patch was tested and it
produces correct value, when this macro is defined (vector of 0xFFFFs is
returned for the EQ case as expected). If VECTOR_STORE_FLAG_VALUE is not
defined, just skip this calculation.
Patch was bootstrapped on pentium4-pc-linux-gnu and regtested for c,c+.
2005-01-04 Uros Bizjak <uros@kss-loka.si>
PR target/17767
* cse.c (fold_rtx) [RTX_COMPARE, RTX_COMM_COMPARE]: Handle
vector modes for (const_arg0 == 0 || const_arg1 == 0). Calculate
true and false value for vector modes. Use VECTOR_STORE_FLAG_VALUE
macro to calcuate true value.
skip_vector_modes: new label.
* simplify-rtx.c (simplify_relational_operation): Fix variable name.
Uros.
Index: cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.327
diff -u -p -r1.327 cse.c
--- cse.c 26 Nov 2004 15:42:36 -0000 1.327
+++ cse.c 4 Jan 2005 08:55:22 -0000
@@ -3871,6 +3871,40 @@ fold_rtx (rtx x, rtx insn)
rtx true_rtx = const_true_rtx, false_rtx = const0_rtx;
enum machine_mode mode_arg1;
+ code = find_comparison_args (code, &folded_arg0, &folded_arg1,
+ &mode_arg0, &mode_arg1);
+ const_arg0 = equiv_constant (folded_arg0);
+ const_arg1 = equiv_constant (folded_arg1);
+
+ if (VECTOR_MODE_P (mode))
+ {
+#ifdef VECTOR_STORE_FLAG_VALUE
+ rtx val = VECTOR_STORE_FLAG_VALUE (mode);
+
+ if (val == NULL_RTX)
+ goto skip_vector_modes;
+
+ if (val == const1_rtx)
+ {
+ true_rtx = CONST1_RTX (mode);
+ }
+ else
+ {
+ int units = GET_MODE_NUNITS (mode);
+ rtvec v;
+ int i;
+
+ v = rtvec_alloc (units);
+ for (i = 0; i < units; i++)
+ RTVEC_ELT (v, i) = val;
+ true_rtx = gen_rtx_raw_CONST_VECTOR (mode, v);
+ }
+ false_rtx = CONST0_RTX (mode);
+#else
+ goto skip_vector_modes;
+#endif
+ }
+
#ifdef FLOAT_STORE_FLAG_VALUE
if (GET_MODE_CLASS (mode) == MODE_FLOAT)
{
@@ -3880,11 +3914,6 @@ fold_rtx (rtx x, rtx insn)
}
#endif
- code = find_comparison_args (code, &folded_arg0, &folded_arg1,
- &mode_arg0, &mode_arg1);
- const_arg0 = equiv_constant (folded_arg0);
- const_arg1 = equiv_constant (folded_arg1);
-
/* If the mode is VOIDmode or a MODE_CC mode, we don't know
what kinds of things are being compared, so we can't do
anything with this comparison. */
@@ -4014,6 +4043,7 @@ fold_rtx (rtx x, rtx insn)
}
}
+ skip_vector_modes:
{
rtx op0 = const_arg0 ? const_arg0 : folded_arg0;
rtx op1 = const_arg1 ? const_arg1 : folded_arg1;
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.219
diff -u -p -r1.219 simplify-rtx.c
--- simplify-rtx.c 3 Jan 2005 19:41:06 -0000 1.219
+++ simplify-rtx.c 4 Jan 2005 08:55:23 -0000
@@ -2757,7 +2757,7 @@ simplify_relational_operation (enum rtx_
#ifdef VECTOR_STORE_FLAG_VALUE
{
int i, units;
- rtvec c;
+ rtvec v;
rtx val = VECTOR_STORE_FLAG_VALUE (mode);
if (val == NULL_RTX)