... if it is an IOR with a constant with all bits set in the mode that is truncated to, for example. Handle that case.
With this patch the problematic situation for the PR81423 testcase isn't even reached; but the next patch fixes that anyway. Bootstrapped and tested on powerpc64-linux {-m32,-m64} and on x86_64-linux. Is this okay for trunk? Segher 2017-07-18 Segher Boessenkool <seg...@kernel.crashing.org> PR rtl-optimization/81423 * simplify-rtx.c (simplify_truncation): Handle truncating an IOR with a constant that is -1 in the truncated to mode. --- gcc/simplify-rtx.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 3bce329..ef41479 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -857,6 +857,15 @@ simplify_truncation (machine_mode mode, rtx op, return simplify_gen_unary (TRUNCATE, mode, XEXP (op, 0), GET_MODE (XEXP (op, 0))); + /* (truncate:A (ior X C)) is (const_int -1) if C is equal to that already, + in mode A. */ + if (GET_CODE (op) == IOR + && SCALAR_INT_MODE_P (mode) + && SCALAR_INT_MODE_P (op_mode) + && CONST_INT_P (XEXP (op, 1)) + && trunc_int_for_mode (INTVAL (XEXP (op, 1)), mode) == -1) + return constm1_rtx; + return NULL_RTX; } -- 1.9.3