simplify-rtx.c (simplify_relational_operation_1): Implement some canonicalization transformations that attempt to simplify...
* simplify-rtx.c (simplify_relational_operation_1): Implement some canonicalization transformations that attempt to simplify integer constant comparisons to become comparisons against zero. From-SVN: r121544
This commit is contained in:
parent
5041541e41
commit
3fa0cacdb5
|
@ -1,3 +1,9 @@
|
|||
2007-02-03 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
* simplify-rtx.c (simplify_relational_operation_1): Implement some
|
||||
canonicalization transformations that attempt to simplify integer
|
||||
constant comparisons to become comparisons against zero.
|
||||
|
||||
2007-02-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
|
||||
|
||||
* builtins.c (fold_builtin_cabs): Fold cabs(x+xi) into
|
||||
|
|
|
@ -3595,28 +3595,68 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode,
|
|||
{
|
||||
enum rtx_code op0code = GET_CODE (op0);
|
||||
|
||||
if (GET_CODE (op1) == CONST_INT)
|
||||
if (op1 == const0_rtx && COMPARISON_P (op0))
|
||||
{
|
||||
if (INTVAL (op1) == 0 && COMPARISON_P (op0))
|
||||
/* If op0 is a comparison, extract the comparison arguments
|
||||
from it. */
|
||||
if (code == NE)
|
||||
{
|
||||
/* If op0 is a comparison, extract the comparison arguments
|
||||
from it. */
|
||||
if (code == NE)
|
||||
{
|
||||
if (GET_MODE (op0) == mode)
|
||||
return simplify_rtx (op0);
|
||||
else
|
||||
return simplify_gen_relational (GET_CODE (op0), mode, VOIDmode,
|
||||
XEXP (op0, 0), XEXP (op0, 1));
|
||||
}
|
||||
else if (code == EQ)
|
||||
{
|
||||
enum rtx_code new_code = reversed_comparison_code (op0, NULL_RTX);
|
||||
if (new_code != UNKNOWN)
|
||||
return simplify_gen_relational (new_code, mode, VOIDmode,
|
||||
XEXP (op0, 0), XEXP (op0, 1));
|
||||
}
|
||||
if (GET_MODE (op0) == mode)
|
||||
return simplify_rtx (op0);
|
||||
else
|
||||
return simplify_gen_relational (GET_CODE (op0), mode, VOIDmode,
|
||||
XEXP (op0, 0), XEXP (op0, 1));
|
||||
}
|
||||
else if (code == EQ)
|
||||
{
|
||||
enum rtx_code new_code = reversed_comparison_code (op0, NULL_RTX);
|
||||
if (new_code != UNKNOWN)
|
||||
return simplify_gen_relational (new_code, mode, VOIDmode,
|
||||
XEXP (op0, 0), XEXP (op0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (op1 == const0_rtx)
|
||||
{
|
||||
/* Canonicalize (GTU x 0) as (NE x 0). */
|
||||
if (code == GTU)
|
||||
return simplify_gen_relational (NE, mode, cmp_mode, op0, op1);
|
||||
/* Canonicalize (LEU x 0) as (EQ x 0). */
|
||||
if (code == LEU)
|
||||
return simplify_gen_relational (EQ, mode, cmp_mode, op0, op1);
|
||||
}
|
||||
else if (op1 == const1_rtx)
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case GE:
|
||||
/* Canonicalize (GE x 1) as (GT x 0). */
|
||||
return simplify_gen_relational (GT, mode, cmp_mode,
|
||||
op0, const0_rtx);
|
||||
case GEU:
|
||||
/* Canonicalize (GEU x 1) as (NE x 0). */
|
||||
return simplify_gen_relational (NE, mode, cmp_mode,
|
||||
op0, const0_rtx);
|
||||
case LT:
|
||||
/* Canonicalize (LT x 1) as (LE x 0). */
|
||||
return simplify_gen_relational (LE, mode, cmp_mode,
|
||||
op0, const0_rtx);
|
||||
case LTU:
|
||||
/* Canonicalize (LTU x 1) as (EQ x 0). */
|
||||
return simplify_gen_relational (EQ, mode, cmp_mode,
|
||||
op0, const0_rtx);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (op1 == constm1_rtx)
|
||||
{
|
||||
/* Canonicalize (LE x -1) as (LT x 0). */
|
||||
if (code == LE)
|
||||
return simplify_gen_relational (LT, mode, cmp_mode, op0, const0_rtx);
|
||||
/* Canonicalize (GT x -1) as (GE x 0). */
|
||||
if (code == GT)
|
||||
return simplify_gen_relational (GE, mode, cmp_mode, op0, const0_rtx);
|
||||
}
|
||||
|
||||
/* (eq/ne (plus x cst1) cst2) simplifies to (eq/ne x (cst2 - cst1)) */
|
||||
|
|
Loading…
Reference in New Issue