public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: Fix mode mismatch error between Loongson builtin arguments and insn operands.
@ 2017-01-30 17:37 Toma Tabacu
  2017-01-31 12:15 ` Matthew Fortune
  0 siblings, 1 reply; 7+ messages in thread
From: Toma Tabacu @ 2017-01-30 17:37 UTC (permalink / raw)
  To: gcc-patches; +Cc: Matthew Fortune, catherine_moore

Hi,

The builtins for the pshufh, psllh, psllw, psrah, psraw, psrlh, psrlw Loongson
instructions have the third argument's type set to UQI while its corresponding
insn operand is in SImode.

This results in the following error when matching insn operands:

../gcc/gcc/include/loongson.h: In function 'test_psllw_s':
../gcc/gcc/include/loongson.h:483:10: error: invalid argument to built-in function
   return __builtin_loongson_psllw_s (s, amount);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This causes the loongson-simd.c and loongson-shift-count-truncated-1.c tests
to fail.

This patch fixes this by wrapping the QImode builtin argument inside a
paradoxical SUBREG with SImode, which will successfully match against the insn
operand.

Tested with mips-mti-elf.

Regards,
Toma

gcc/

	* config/mips/mips.c (mips_expand_builtin_insn): Put the QImode
	argument of the pshufh, psllh, psllw, psrah, psraw, psrlh, psrlw
	builtins into an SImode paradoxical SUBREG.

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index da7fa8f..f1ca6e2 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -16574,6 +16574,20 @@ mips_expand_builtin_insn (enum insn_code icode, unsigned int nops,
 
   switch (icode)
     {
+    /* The third argument needs to be in SImode in order to succesfully match
+       the operand from the insn definition.  */
+    case CODE_FOR_loongson_pshufh:
+    case CODE_FOR_loongson_psllh:
+    case CODE_FOR_loongson_psllw:
+    case CODE_FOR_loongson_psrah:
+    case CODE_FOR_loongson_psraw:
+    case CODE_FOR_loongson_psrlh:
+    case CODE_FOR_loongson_psrlw:
+      gcc_assert (has_target_p && nops == 3 && ops[2].mode == QImode);
+      ops[2].value = lowpart_subreg (SImode, ops[2].value, QImode);
+      ops[2].mode = SImode;
+      break;
+
     case CODE_FOR_msa_addvi_b:
     case CODE_FOR_msa_addvi_h:
     case CODE_FOR_msa_addvi_w:

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

end of thread, other threads:[~2017-02-07 10:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-30 17:37 [PATCH] MIPS: Fix mode mismatch error between Loongson builtin arguments and insn operands Toma Tabacu
2017-01-31 12:15 ` Matthew Fortune
2017-02-01 10:17   ` Toma Tabacu
2017-02-02 23:29     ` Matthew Fortune
2017-02-06 15:20       ` Toma Tabacu
2017-02-06 15:40         ` Matthew Fortune
2017-02-07 10:39           ` Toma Tabacu

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