diff mbox series

[i386] : Fix PR88938, ICE in extract_insn

Message ID CAFULd4bHLC_HmN6Xvd1dSEvKnhA3A2AFqnRH1FuSoenkZgOeYQ@mail.gmail.com
State New
Headers show
Series [i386] : Fix PR88938, ICE in extract_insn | expand

Commit Message

Uros Bizjak Jan. 21, 2019, 8:18 p.m. UTC
We need to sanitize operands to fit insn predicates.

2019-01-21  Uroš Bizjak  <ubizjak@gmail.com>

    PR target/88938
    * config/i386/i386.c (ix86_expand_builtin) [case IX86_BUILTIN_BEXTRI32,
    case IX86_BUILTIN_BEXTRI64]: Sanitize operands.

testsuite/ChangeLog:

2019-01-21  Uroš Bizjak  <ubizjak@gmail.com>

    PR target/88938
    * gcc.target/i386/pr88938.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline, will be backported to release branches.

Uros.
diff mbox series

Patch

Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 268116)
+++ config/i386/i386.c	(working copy)
@@ -37215,6 +37215,16 @@  ix86_expand_builtin (tree exp, rtx target, rtx sub
           unsigned char lsb_index = INTVAL (op1) & 0xFF;
           op1 = GEN_INT (length);
           op2 = GEN_INT (lsb_index);
+
+	  mode1 = insn_data[icode].operand[1].mode;
+	  if (!insn_data[icode].operand[1].predicate (op0, mode1))
+	    op0 = copy_to_mode_reg (mode1, op0);
+
+	  mode0 = insn_data[icode].operand[0].mode;
+	  if (target == 0
+	      || !register_operand (target, mode0))
+	    target = gen_reg_rtx (mode0);
+
           pat = GEN_FCN (icode) (target, op0, op1, op2);
           if (pat)
             emit_insn (pat);
Index: testsuite/gcc.target/i386/pr88938.c
===================================================================
--- testsuite/gcc.target/i386/pr88938.c	(nonexistent)
+++ testsuite/gcc.target/i386/pr88938.c	(working copy)
@@ -0,0 +1,5 @@ 
+/* PR target/88938 */
+/* { dg-do compile } */
+/* { dg-options "-Og -fno-tree-ccp -fno-tree-fre -mtbm" } */
+
+#include "tbm-bextri-1.c"