public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] simplify-rtx: The truncation of an IOR can have all bits set (PR81423)
@ 2017-07-18 19:36 Segher Boessenkool
  2017-07-18 19:36 ` [PATCH 2/2] combine: Fix for PR81423 Segher Boessenkool
  2017-07-19  6:19 ` [PATCH 1/2] simplify-rtx: The truncation of an IOR can have all bits set (PR81423) Jeff Law
  0 siblings, 2 replies; 12+ messages in thread
From: Segher Boessenkool @ 2017-07-18 19:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool

... 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.

---
 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;
 }
 \f
-- 
1.9.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-08-08 16:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-18 19:36 [PATCH 1/2] simplify-rtx: The truncation of an IOR can have all bits set (PR81423) Segher Boessenkool
2017-07-18 19:36 ` [PATCH 2/2] combine: Fix for PR81423 Segher Boessenkool
2017-07-19  6:19 ` [PATCH 1/2] simplify-rtx: The truncation of an IOR can have all bits set (PR81423) Jeff Law
2017-07-19 19:03   ` Segher Boessenkool
2017-07-24  8:56   ` Segher Boessenkool
2017-07-24 22:06     ` Jeff Law
2017-07-25 11:25       ` Segher Boessenkool
2017-08-07 22:33         ` Segher Boessenkool
2017-08-08 16:27           ` Jeff Law
2017-07-25 11:31     ` Kyrill Tkachov
2017-07-25 22:11       ` Segher Boessenkool
2017-07-26 20:50         ` Mike Stump

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).