From b9750434708d2f3cc276d52c3f772c277fd6f4a7 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Sun, 23 Jan 2005 15:43:56 +0000 Subject: [PATCH] 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 From-SVN: r94114 --- gcc/ChangeLog | 7 +++++++ gcc/combine.c | 14 ++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ce737615e63..68bc9493ac3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-01-23 Roger Sayle + Eric Botcazou + + * 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. + 2005-01-23 Kazu Hirata * alias.c, c-common.h, c-incpath.c, c-incpath.h, expr.c, diff --git a/gcc/combine.c b/gcc/combine.c index dca4d971a1e..0baeb981500 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 -- 2.30.2