public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] x86: Provide expanders for truncdisi2 and friends.
@ 2020-07-11 23:28 Roger Sayle
  2020-07-13  6:53 ` Richard Biener
  0 siblings, 1 reply; 7+ messages in thread
From: Roger Sayle @ 2020-07-11 23:28 UTC (permalink / raw)
  To: gcc-patches


Even by my standards, this is an odd patch.  This adds expanders to
i386.md requesting that integer truncations be represented in RTL
using SUBREGs.  This exactly matches the (current) default behaviour
when TARGET_TRULY_NOOP_TRUNCATION is undefined.  Hence this patch
is mostly for documentation/teaching purposes, so that i386.md is a
template or role model for the patterns that a backend should provide.

As explained in my earlier post, defining TARGET_TRULY_NOOP_TRUNCATION
to always return false in the i386/x86_64 backend, results in 603
additional unexpected failures.  Adding these expanders avoids the
majority (412) of those regressions.

I'm not proposing that i386/x86_64 redefine TARGET_TRULY_NOOP_TRUNCATION
but these placeholder expanders may provide the backend the flexibility
of that option in the future, but it also helps to test some less frequently
invoked corners of the middle-end.

This patch has been tested on x86_64-pc-linux-gnu with a full "make
bootstrap" and "make -k check" with no new failures, indeed there
are (should be) absolutely no code changes with this patch.

Might these changes be of interest?  If not, at least this patch
is now archived on gcc-patches for future generations.


2020-07-12  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* config/i386/i386.md (truncdi<SWI124>2, truncsi<SWI12>2,
	trunchiqi2): New expanders to make the intended representation
	of scalar integer truncations explicit.

Thoughts?
Roger
--
Roger Sayle
NextMove Software
Cambridge, UK



^ permalink raw reply	[flat|nested] 7+ messages in thread
* RE: [PATCH] x86: Provide expanders for truncdisi2 and friends.
@ 2020-07-11 23:33 Roger Sayle
  0 siblings, 0 replies; 7+ messages in thread
From: Roger Sayle @ 2020-07-11 23:33 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1778 bytes --]


Doh! With the attachment.


-----Original Message-----
From: Roger Sayle <roger@nextmovesoftware.com> 
Sent: 12 July 2020 00:29
To: 'gcc-patches@gcc.gnu.org' <gcc-patches@gcc.gnu.org>
Subject: [PATCH] x86: Provide expanders for truncdisi2 and friends.


Even by my standards, this is an odd patch.  This adds expanders to i386.md
requesting that integer truncations be represented in RTL using SUBREGs.
This exactly matches the (current) default behaviour when
TARGET_TRULY_NOOP_TRUNCATION is undefined.  Hence this patch is mostly for
documentation/teaching purposes, so that i386.md is a template or role model
for the patterns that a backend should provide.

As explained in my earlier post, defining TARGET_TRULY_NOOP_TRUNCATION to
always return false in the i386/x86_64 backend, results in 603 additional
unexpected failures.  Adding these expanders avoids the majority (412) of
those regressions.

I'm not proposing that i386/x86_64 redefine TARGET_TRULY_NOOP_TRUNCATION but
these placeholder expanders may provide the backend the flexibility of that
option in the future, but it also helps to test some less frequently invoked
corners of the middle-end.

This patch has been tested on x86_64-pc-linux-gnu with a full "make
bootstrap" and "make -k check" with no new failures, indeed there are
(should be) absolutely no code changes with this patch.

Might these changes be of interest?  If not, at least this patch is now
archived on gcc-patches for future generations.


2020-07-12  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
	* config/i386/i386.md (truncdi<SWI124>2, truncsi<SWI12>2,
	trunchiqi2): New expanders to make the intended representation
	of scalar integer truncations explicit.

Thoughts?
Roger
--
Roger Sayle
NextMove Software
Cambridge, UK


[-- Attachment #2: patchd2.txt --]
[-- Type: text/plain, Size: 1004 bytes --]

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index d0ecd9e..4929c05 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -5144,6 +5144,39 @@
     }
 })
 \f
+;; Integer conversions
+
+(define_expand "truncdi<SWI124:mode>2"
+  [(set (match_operand:SWI124 0 "register_operand")
+	(subreg:SWI124
+	  (match_operand:DI 1 "register_operand")
+	  0))]
+  ""
+{
+  operands[1] = force_reg (DImode, operands[1]);
+})
+
+(define_expand "truncsi<SWI12:mode>2"
+  [(set (match_operand:SWI12 0 "register_operand")
+	(subreg:SWI12
+	  (match_operand:SI 1 "register_operand")
+	  0))]
+  ""
+{
+  operands[1] = force_reg (SImode, operands[1]);
+})
+
+(define_expand "trunchiqi2"
+  [(set (match_operand:QI 0 "register_operand")
+	(subreg:QI
+	  (match_operand:HI 1 "register_operand")
+	  0))]
+  ""
+{
+  operands[1] = force_reg (HImode, operands[1]);
+})
+
+\f
 ;; Load effective address instructions
 
 (define_insn_and_split "*lea<mode>"

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

end of thread, other threads:[~2020-07-17  7:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-11 23:28 [PATCH] x86: Provide expanders for truncdisi2 and friends Roger Sayle
2020-07-13  6:53 ` Richard Biener
2020-07-13 14:50   ` Roger Sayle
2020-07-14 14:16     ` Richard Biener
2020-07-16 11:07       ` Roger Sayle
2020-07-17  7:27         ` Richard Biener
2020-07-11 23:33 Roger Sayle

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