Jiawei <jia...@iscas.ac.cn> writes: > This patch adds a new simplification rule to `simplify-rtx.cc` that > handles a common bit manipulation pattern involving a single-bit set > and clear followed by XOR. > > The transformation targets RTL of the form: > > (xor (and (rotate (~1) A) B) (ashift 1 A)) > > which is semantically equivalent to: > > B | (1 << A) > > - v3 log: > Update RTL format, remove commas. > Only apply on SHIFT_COUNT_TRUNCATED target. > check '!side_effects_p' on XEXP (op1, 1). > > gcc/ChangeLog: > > * simplify-rtx.cc (simplify_context::simplify_binary_operation_1): > Handle > more logical simplifications. > > --- > gcc/simplify-rtx.cc | 14 ++++++++++++++ > 1 file changed, 14 insertions(+)
OK, thanks. Richard > > diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc > index b34fd2f4b9e..cbe61b49bf6 100644 > --- a/gcc/simplify-rtx.cc > +++ b/gcc/simplify-rtx.cc > @@ -4063,6 +4063,20 @@ simplify_context::simplify_binary_operation_1 > (rtx_code code, > && rtx_equal_p (XEXP (XEXP (op0, 0), 0), op1)) > return simplify_gen_binary (IOR, mode, XEXP (op0, 1), op1); > > + /* Convert (xor (and (rotate (~1) A) B) (ashift 1 A)) > + into B | (1 << A). */ > + if (SHIFT_COUNT_TRUNCATED > + && GET_CODE (op0) == AND > + && GET_CODE (XEXP (op0, 0)) == ROTATE > + && CONST_INT_P (XEXP (XEXP (op0, 0), 0)) > + && INTVAL (XEXP (XEXP (op0, 0), 0)) == -2 > + && GET_CODE (op1) == ASHIFT > + && CONST_INT_P (XEXP (op1, 0)) > + && INTVAL (XEXP (op1, 0)) == 1 > + && rtx_equal_p (XEXP (XEXP (op0, 0), 1), XEXP (op1, 1)) > + && !side_effects_p (XEXP (op1, 1))) > + return simplify_gen_binary (IOR, mode, XEXP (op0, 1), op1); > + > tem = simplify_with_subreg_not (code, mode, op0, op1); > if (tem) > return tem;