From: Dominik Vogt Date: Fri, 2 Dec 2016 08:32:40 +0000 (+0000) Subject: Do not simplify "(and (reg) (const bit)" to if_then_else. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=32ff7e39c15206dada1406bdc06e18db9e02d248;p=gcc.git Do not simplify "(and (reg) (const bit)" to if_then_else. combine_simplify_rtx() tries to replace rtx expressions with just two possible values with an experession that uses if_then_else: (if_then_else (condition) (value1) (value2)) If the original expression is e.g. (and (reg) (const_int 2)) where the constant is the mask for a single bit, the replacement results in a more complex expression than before: (if_then_else (ne (zero_extract (reg) (1) (31))) (2) (0)) Similar replacements are done for (signextend (and ...)) (zeroextend (and ...)) Suppress the replacement this special case in if_then_else_cond(). gcc/ChangeLog: 2016-12-02 Dominik Vogt * combine.c (combine_simplify_rtx): Suppress replacement of "(and (reg) (const_int bit))" with "if_then_else". From-SVN: r243162 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e357932cc18..a3fcd8b6d0b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-12-02 Dominik Vogt + + * combine.c (combine_simplify_rtx): Suppress replacement of + "(and (reg) (const_int bit))" with "if_then_else". + 2016-12-02 Dominik Vogt PR target/77822 diff --git a/gcc/combine.c b/gcc/combine.c index b4294532296..7ba634af532 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -5602,6 +5602,18 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest, && OBJECT_P (SUBREG_REG (XEXP (x, 0))))))) { rtx cond, true_rtx, false_rtx; + unsigned HOST_WIDE_INT nz; + + /* If the operation is an AND wrapped in a SIGN_EXTEND or ZERO_EXTEND with + either operand being just a constant single bit value, do nothing since + IF_THEN_ELSE is likely to increase the expression's complexity. */ + if (HWI_COMPUTABLE_MODE_P (mode) + && pow2p_hwi (nz = nonzero_bits (x, mode)) + && ! ((code == SIGN_EXTEND || code == ZERO_EXTEND) + && GET_CODE (XEXP (x, 0)) == AND + && CONST_INT_P (XEXP (XEXP (x, 0), 0)) + && UINTVAL (XEXP (XEXP (x, 0), 0)) == nz)) + return x; cond = if_then_else_cond (x, &true_rtx, &false_rtx); if (cond != 0