aboutsummaryrefslogtreecommitdiff
path: root/gcc/combine.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2005-01-23 15:43:56 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2005-01-23 15:43:56 +0000
commitb9750434708d2f3cc276d52c3f772c277fd6f4a7 (patch)
treebcf4c83c4d6cd68bd4c7ba659abafda685abfe03 /gcc/combine.c
parent6ccf2f7d07a74e74fbf37eb38c7de079a2278ed5 (diff)
downloadgcc-b9750434708d2f3cc276d52c3f772c277fd6f4a7.zip
gcc-b9750434708d2f3cc276d52c3f772c277fd6f4a7.tar.gz
gcc-b9750434708d2f3cc276d52c3f772c277fd6f4a7.tar.bz2
combine.c (simplify_logical): Only simplify logical expressions of the form ior(and(x,y),z) by the inverse...
* combine.c (simplify_logical): Only simplify logical expressions of the form ior(and(x,y),z) by the inverse distributive law if the result is cheaper than the original. Co-Authored-By: Eric Botcazou <ebotcazou@libertysurf.fr> From-SVN: r94114
Diffstat (limited to 'gcc/combine.c')
-rw-r--r--gcc/combine.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index dca4d97..0baeb98 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -5574,26 +5574,28 @@ simplify_logical (rtx x)
if (GET_CODE (op0) == AND)
{
- x = apply_distributive_law
+ rtx tmp = apply_distributive_law
(gen_binary (AND, mode,
gen_binary (IOR, mode, XEXP (op0, 0), op1),
gen_binary (IOR, mode, XEXP (op0, 1),
copy_rtx (op1))));
- if (GET_CODE (x) != IOR)
- return x;
+ if (GET_CODE (tmp) != IOR
+ && rtx_cost (tmp, SET) < rtx_cost (x, SET))
+ return tmp;
}
if (GET_CODE (op1) == AND)
{
- x = apply_distributive_law
+ rtx tmp = apply_distributive_law
(gen_binary (AND, mode,
gen_binary (IOR, mode, XEXP (op1, 0), op0),
gen_binary (IOR, mode, XEXP (op1, 1),
copy_rtx (op0))));
- if (GET_CODE (x) != IOR)
- return x;
+ if (GET_CODE (tmp) != IOR
+ && rtx_cost (tmp, SET) < rtx_cost (x, SET))
+ return tmp;
}
/* Convert (ior (ashift A CX) (lshiftrt A CY)) where CX+CY equals the