This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Avoid bogues usages of operand_subword
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com, patches at x86-64 dot org
- Subject: Avoid bogues usages of operand_subword
- From: Jan Hubicka <jh at suse dot cz>
- Date: Sat, 2 Jun 2001 12:35:14 +0200
Hi,
this patch avoids two usages of operand_subword, that are bogus in
SUBREG_BYTE world, as the lowpart is incorrectly takes in little
endian machines. I will check rest of gcc later for similar cases.
Sat Jun 2 12:32:56 CEST 2001 Jan Hubicka <jh@suse.cz>
* combine.c (if_then_else_cond): Use simplify_subreg instead
of operand_subword.
* integreate.c (sub_constants): Likewise.
Index: combine.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/combine.c,v
retrieving revision 1.206
diff -c -3 -p -r1.206 combine.c
*** combine.c 2001/05/27 10:35:08 1.206
--- combine.c 2001/06/02 10:21:48
*************** if_then_else_cond (x, ptrue, pfalse)
*** 7293,7321 ****
return cond0;
}
! /* If X is a normal SUBREG with both inner and outer modes integral,
! we can narrow both the true and false values of the inner expression,
! if there is a condition. */
! else if (code == SUBREG && GET_MODE_CLASS (mode) == MODE_INT
! && GET_MODE_CLASS (GET_MODE (SUBREG_REG (x))) == MODE_INT
! && GET_MODE_SIZE (mode) <= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))
&& 0 != (cond0 = if_then_else_cond (SUBREG_REG (x),
&true0, &false0)))
{
! if ((GET_CODE (SUBREG_REG (x)) == REG
! || GET_CODE (SUBREG_REG (x)) == MEM
! || CONSTANT_P (SUBREG_REG (x)))
! && GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) > UNITS_PER_WORD
! && (WORDS_BIG_ENDIAN || SUBREG_BYTE (x) >= UNITS_PER_WORD))
! {
! true0 = operand_subword (true0, SUBREG_BYTE (x) / UNITS_PER_WORD, 0,
! GET_MODE (SUBREG_REG (x)));
! false0 = operand_subword (false0, SUBREG_BYTE (x) / UNITS_PER_WORD, 0,
! GET_MODE (SUBREG_REG (x)));
! }
! *ptrue = force_to_mode (true0, mode, ~(HOST_WIDE_INT) 0, NULL_RTX, 0);
! *pfalse
! = force_to_mode (false0, mode, ~(HOST_WIDE_INT) 0, NULL_RTX, 0);
return cond0;
}
--- 7293,7308 ----
return cond0;
}
! /* If X is a SUBREG, we can narrow both the true and false values
! if the inner expression, if there is a condition. */
! else if (code == SUBREG
&& 0 != (cond0 = if_then_else_cond (SUBREG_REG (x),
&true0, &false0)))
{
! *ptrue = simplify_gen_subreg (mode, true0,
! GET_MODE (SUBREG_REG (x)), SUBREG_BYTE (x));
! *pfalse = simplify_gen_subreg (mode, false0,
! GET_MODE (SUBREG_REG (x)), SUBREG_BYTE (x));
return cond0;
}
Index: integrate.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/integrate.c,v
retrieving revision 1.145
diff -c -3 -p -r1.145 integrate.c
*** integrate.c 2001/05/23 22:53:54 1.145
--- integrate.c 2001/06/02 10:21:51
*************** subst_constants (loc, insn, map, memonly
*** 2411,2429 ****
valid. We handle two cases: extracting a full word in an
integral mode and extracting the low part. */
subst_constants (&inner, NULL_RTX, map, 0);
- if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT
- && GET_MODE_SIZE (GET_MODE (x)) == UNITS_PER_WORD
- && GET_MODE (SUBREG_REG (x)) != VOIDmode)
- new = operand_subword (inner, SUBREG_BYTE (x) / UNITS_PER_WORD,
- 0, GET_MODE (SUBREG_REG (x)));
-
- cancel_changes (num_changes);
- if (new == 0 && subreg_lowpart_p (x))
- new = gen_lowpart_common (GET_MODE (x), inner);
-
if (new)
validate_change (insn, loc, new, 1);
return;
}
--- 2411,2424 ----
valid. We handle two cases: extracting a full word in an
integral mode and extracting the low part. */
subst_constants (&inner, NULL_RTX, map, 0);
+ new = simplify_gen_subreg (GET_MODE (x), inner,
+ GET_MODE (SUBREG_REG (x)),
+ SUBREG_BYTE (x));
if (new)
validate_change (insn, loc, new, 1);
+ else
+ cancel_changes (num_changes);
return;
}