]> gcc.gnu.org Git - gcc.git/commitdiff
Fix unrecognizable insn due to illegal immediate_operand (const_int 255) of QImode.
authorliuhongt <hongtao.liu@intel.com>
Mon, 28 Nov 2022 01:59:47 +0000 (09:59 +0800)
committerliuhongt <hongtao.liu@intel.com>
Thu, 1 Dec 2022 03:31:37 +0000 (11:31 +0800)
For __builtin_ia32_vec_set_v16qi (a, -1, 2) with
!flag_signed_char. it's transformed to
__builtin_ia32_vec_set_v16qi (_4, 255, 2) in the gimple,
and expanded to (const_int 255) in the rtl. But for immediate_operand,
it expects (const_int 255) to be signed extended to
(const_int -1). The mismatch caused an unrecognizable insn error.

The patch converts (const_int 255) to (const_int -1) in the backend
expander.

gcc/ChangeLog:

PR target/107863
* config/i386/i386-expand.cc (ix86_expand_vec_set_builtin):
Convert op1 to target mode whenever mode mismatch.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr107863.c: New test.

gcc/config/i386/i386-expand.cc
gcc/testsuite/gcc.target/i386/pr107863.c [new file with mode: 0644]

index d26e7e41445d2f4efcadaaf88c380a45c5eb5b13..ec3921bdc6204306bb46a30a653eab10c758dba2 100644 (file)
@@ -12476,7 +12476,7 @@ ix86_expand_vec_set_builtin (tree exp)
   op1 = expand_expr (arg1, NULL_RTX, mode1, EXPAND_NORMAL);
   elt = get_element_number (TREE_TYPE (arg0), arg2);
 
-  if (GET_MODE (op1) != mode1 && GET_MODE (op1) != VOIDmode)
+  if (GET_MODE (op1) != mode1)
     op1 = convert_modes (mode1, GET_MODE (op1), op1, true);
 
   op0 = force_reg (tmode, op0);
diff --git a/gcc/testsuite/gcc.target/i386/pr107863.c b/gcc/testsuite/gcc.target/i386/pr107863.c
new file mode 100644 (file)
index 0000000..99fd85d
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O" } */
+
+typedef char v16qi __attribute__((vector_size(16)));
+
+v16qi foo(v16qi a){
+  return __builtin_ia32_vec_set_v16qi (a, -1, 2);
+}
This page took 0.104065 seconds and 5 git commands to generate.