public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix improper combiner optimization of mixed mode vector/scalar expressions (PR 79365)
@ 2017-02-03 20:03 Walter Lee
  2017-02-03 20:16 ` Walter Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Walter Lee @ 2017-02-03 20:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: segher, guybe

Hi,

In looking at PR 79365 I found that the problem is actually in the
combiner.  The combiner sometimes applies scalar optimizations to
vector context where they are invalid.  i.e. (a > b) >> 1 can optimize
to 0 if ">" is a scalar op but not if it is a vector op.  The reason
this shows up on tile* and not other architectures is because tile*
uses the same register file for both scalars and vectors, so the
combiner sees these mixed mode expressions on tile* that would go
through memory on other architectures.

I have found two places where this improper optimization occurs.
Patch below.

Ok to commit?

Thanks,

Walter

diff --git a/gcc/combine.c b/gcc/combine.c
index 28133ff..8f2615e 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -7267,6 +7267,7 @@ expand_field_assignment (const_rtx x)
        else if (GET_CODE (SET_DEST (x)) == SUBREG
  	       /* We need SUBREGs to compute nonzero_bits properly.  */
  	       && nonzero_sign_valid
+	       && !VECTOR_MODE_P (GET_MODE (SET_DEST (x)))
  	       && (((GET_MODE_SIZE (GET_MODE (SET_DEST (x)))
  		     + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
  		   == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (SET_DEST (x))))
@@ -13030,6 +13031,7 @@ record_dead_and_set_regs_1 (rtx dest, const_rtx setter, void *data)
  	record_value_for_reg (dest, record_dead_insn, SET_SRC (setter));
        else if (GET_CODE (setter) == SET
  	       && GET_CODE (SET_DEST (setter)) == SUBREG
+	       && !VECTOR_MODE_P (GET_MODE (SET_DEST (setter)))
  	       && SUBREG_REG (SET_DEST (setter)) == dest
  	       && GET_MODE_PRECISION (GET_MODE (dest)) <= BITS_PER_WORD
  	       && subreg_lowpart_p (SET_DEST (setter)))
-- 
2.7.2

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

end of thread, other threads:[~2017-04-28 20:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-03 20:03 [PATCH] Fix improper combiner optimization of mixed mode vector/scalar expressions (PR 79365) Walter Lee
2017-02-03 20:16 ` Walter Lee
2017-02-03 23:22 ` Segher Boessenkool
2017-02-04 17:51   ` Walter Lee
2017-04-28 22:09 ` Jeff Law

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