Commit aa2d0bc3 by Alexandre Oliva Committed by Alexandre Oliva

combine.c (simplify_comparison, [...]): Do not drop the extend if we'd have to…

combine.c (simplify_comparison, [...]): Do not drop the extend if we'd have to add a paradoxical subreg later.

gcc/ChangeLog:
* combine.c (simplify_comparison, case SIGN_EXTEND, ZERO_EXTEND):
Do not drop the extend if we'd have to add a paradoxical subreg
later.  Include optabs.h and insn-codes.h.
* Makefile.in (combine.o): Depend on $(OPTABS_H).
gcc/testsuite/ChangeLog:
* gcc.c-torture/execute/20050203-1.c: New.

From-SVN: r94655
parent f1a3e333
2005-02-03 Alexandre Oliva <aoliva@redhat.com>
* combine.c (simplify_comparison, case SIGN_EXTEND, ZERO_EXTEND):
Do not drop the extend if we'd have to add a paradoxical subreg
later. Include optabs.h and insn-codes.h.
* Makefile.in (combine.o): Depend on $(OPTABS_H).
2005-02-02 Roger Sayle <roger@eyesopen.com> 2005-02-02 Roger Sayle <roger@eyesopen.com>
PR middle-end/19405 PR middle-end/19405
......
...@@ -2046,7 +2046,7 @@ et-forest.o : et-forest.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) et-forest. ...@@ -2046,7 +2046,7 @@ et-forest.o : et-forest.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) et-forest.
combine.o : combine.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ combine.o : combine.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(FLAGS_H) function.h insn-config.h $(INSN_ATTR_H) $(REGS_H) $(EXPR_H) \ $(FLAGS_H) function.h insn-config.h $(INSN_ATTR_H) $(REGS_H) $(EXPR_H) \
rtlhooks-def.h $(BASIC_BLOCK_H) $(RECOG_H) real.h hard-reg-set.h \ rtlhooks-def.h $(BASIC_BLOCK_H) $(RECOG_H) real.h hard-reg-set.h \
toplev.h $(TM_P_H) $(TREE_H) $(TARGET_H) output.h $(PARAMS_H) toplev.h $(TM_P_H) $(TREE_H) $(TARGET_H) output.h $(PARAMS_H) $(OPTABS_H)
regclass.o : regclass.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ regclass.o : regclass.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
hard-reg-set.h $(FLAGS_H) $(BASIC_BLOCK_H) $(REGS_H) insn-config.h \ hard-reg-set.h $(FLAGS_H) $(BASIC_BLOCK_H) $(REGS_H) insn-config.h \
$(RECOG_H) reload.h real.h toplev.h function.h output.h $(GGC_H) \ $(RECOG_H) reload.h real.h toplev.h function.h output.h $(GGC_H) \
......
...@@ -90,6 +90,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -90,6 +90,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "real.h" #include "real.h"
#include "toplev.h" #include "toplev.h"
#include "target.h" #include "target.h"
#include "optabs.h"
#include "insn-codes.h"
#include "rtlhooks-def.h" #include "rtlhooks-def.h"
/* Include output.h for dump_file. */ /* Include output.h for dump_file. */
#include "output.h" #include "output.h"
...@@ -10054,16 +10056,22 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1) ...@@ -10054,16 +10056,22 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1)
break; break;
case SIGN_EXTEND: case SIGN_EXTEND:
/* Can simplify (compare (zero/sign_extend FOO) CONST) /* Can simplify (compare (zero/sign_extend FOO) CONST) to
to (compare FOO CONST) if CONST fits in FOO's mode and we (compare FOO CONST) if CONST fits in FOO's mode and we
are either testing inequality or have an unsigned comparison are either testing inequality or have an unsigned
with ZERO_EXTEND or a signed comparison with SIGN_EXTEND. */ comparison with ZERO_EXTEND or a signed comparison with
if (! unsigned_comparison_p SIGN_EXTEND. But don't do it if we don't have a compare
&& (GET_MODE_BITSIZE (GET_MODE (XEXP (op0, 0))) insn of the given mode, since we'd have to revert it
<= HOST_BITS_PER_WIDE_INT) later on, and then we wouldn't know whether to sign- or
zero-extend. */
mode = GET_MODE (XEXP (op0, 0));
if (mode != VOIDmode && GET_MODE_CLASS (mode) == MODE_INT
&& ! unsigned_comparison_p
&& (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
&& ((unsigned HOST_WIDE_INT) const_op && ((unsigned HOST_WIDE_INT) const_op
< (((unsigned HOST_WIDE_INT) 1 < (((unsigned HOST_WIDE_INT) 1
<< (GET_MODE_BITSIZE (GET_MODE (XEXP (op0, 0))) - 1))))) << (GET_MODE_BITSIZE (mode) - 1))))
&& cmp_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
{ {
op0 = XEXP (op0, 0); op0 = XEXP (op0, 0);
continue; continue;
...@@ -10139,11 +10147,12 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1) ...@@ -10139,11 +10147,12 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1)
/* ... fall through ... */ /* ... fall through ... */
case ZERO_EXTEND: case ZERO_EXTEND:
if ((unsigned_comparison_p || equality_comparison_p) mode = GET_MODE (XEXP (op0, 0));
&& (GET_MODE_BITSIZE (GET_MODE (XEXP (op0, 0))) if (mode != VOIDmode && GET_MODE_CLASS (mode) == MODE_INT
<= HOST_BITS_PER_WIDE_INT) && (unsigned_comparison_p || equality_comparison_p)
&& ((unsigned HOST_WIDE_INT) const_op && (GET_MODE_BITSIZE (mode) <= HOST_BITS_PER_WIDE_INT)
< GET_MODE_MASK (GET_MODE (XEXP (op0, 0))))) && ((unsigned HOST_WIDE_INT) const_op < GET_MODE_MASK (mode))
&& cmp_optab->handlers[(int) mode].insn_code != CODE_FOR_nothing)
{ {
op0 = XEXP (op0, 0); op0 = XEXP (op0, 0);
continue; continue;
......
2005-02-03 Alexandre Oliva <aoliva@redhat.com>
* gcc.c-torture/execute/20050203-1.c: New.
2005-02-03 Dorit Naishlos <dorit@il.ibm.com> 2005-02-03 Dorit Naishlos <dorit@il.ibm.com>
* gcc.dg/vect/vect-85.c: Remove xfail. * gcc.dg/vect/vect-85.c: Remove xfail.
......
/* Reduced testcase extracted from Samba source code. */
#include <stdlib.h>
static void __attribute__((__noinline__))
foo (unsigned char *p) {
*p = 0x81;
}
static void __attribute__((__noinline__))
bar (int x) {
asm ("");
}
int main() {
unsigned char b;
foo(&b);
if (b & 0x80)
{
bar (b & 0x7f);
exit (0);
}
else
{
bar (b & 1);
abort ();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment