This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
testing __builtin_constant_p() may SUBREGs
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: 22 Feb 2003 11:23:56 -0300
- Subject: testing __builtin_constant_p() may SUBREGs
- Organization: GCC Team, Red Hat
There's this machine that doesn't have a 32-bit compare instruction,
but we still wanted int to be 32-bits wide. It turns out that
builtin_constant_p() didn't quite work, because the compare with zero
in gcc.c-torture/compile/20000922-1.c would expand into loading the
high and low parts of the constant_p_rtx into 16-bit registers,
ior-ing them, and then comparing the result with 0. Problem was that
the function that replaces constant_p_rtx with 0 or 1 didn't know to
look for it inside SUBREGs. This patch fixes it. Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva at redhat dot com>
* builtins.c (purge_builtin_constant_p): Handle subreg of
constant_p_rtx too.
Index: gcc/builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.180
diff -u -p -r1.180 builtins.c
--- gcc/builtins.c 22 Feb 2003 04:16:17 -0000 1.180
+++ gcc/builtins.c 22 Feb 2003 14:19:43 -0000
@@ -4952,9 +4952,12 @@ purge_builtin_constant_p ()
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
if (INSN_P (insn)
&& (set = single_set (insn)) != NULL_RTX
- && GET_CODE (SET_SRC (set)) == CONSTANT_P_RTX)
+ && (GET_CODE (arg = SET_SRC (set)) == CONSTANT_P_RTX
+ || (GET_CODE (arg) == SUBREG
+ && (GET_CODE (arg = SUBREG_REG (arg))
+ == CONSTANT_P_RTX))))
{
- arg = XEXP (SET_SRC (set), 0);
+ arg = XEXP (arg, 0);
new = CONSTANT_P (arg) ? const1_rtx : const0_rtx;
validate_change (insn, &SET_SRC (set), new, 0);
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva at {redhat dot com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva at {lsd dot ic dot unicamp dot br, gnu.org}
Free Software Evangelist Professional serial bug killer