Message ID | 0926f163a7f91c101e34cff5cf7926506d208517.1500380707.git.segher@kernel.crashing.org |
---|---|
State | New |
Headers | show |
On 07/18/2017 01:36 PM, Segher Boessenkool wrote: > ... 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 <segher@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. OK. A testcase would be advisable :-) jeff
On Wed, Jul 19, 2017 at 12:19:32AM -0600, Jeff Law wrote: > On 07/18/2017 01:36 PM, Segher Boessenkool wrote: > > ... 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 <segher@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. > OK. A testcase would be advisable :-) Thanks. Yes, I have one, it's not ready yet though (I'm making it not target specific, it seems ideal for torturing). Segher
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; }