From e5f5658166c1c2edd1a7f38af5478d133533c580 Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Thu, 6 Apr 2017 20:49:43 +0200 Subject: [PATCH] re PR target/79733 (ICE in int_mode_for_mode, at stor-layout.c:406) PR target/79733 * config/i386/i386.c (ix86_expand_builtin) : Determine insn operand mode from insn data. Convert operands to insn operand mode. Copy operands that don't satisfy insn predicate to a register. testsuite/ChangeLog: PR target/79733 * gcc.target/i386/pr79733.c: New test. From-SVN: r246739 --- gcc/ChangeLog | 8 +++ gcc/config/i386/i386.c | 73 ++++++++++++------------- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/gcc.target/i386/pr79733.c | 23 ++++++++ 4 files changed, 71 insertions(+), 38 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr79733.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33d77cfe58e..31b7a8d4c0a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-04-06 Uros Bizjak + + PR target/79733 + * config/i386/i386.c (ix86_expand_builtin) + : Determine insn operand + mode from insn data. Convert operands to insn operand mode. + Copy operands that don't satisfy insn predicate to a register. + 2017-04-06 Sam Thursfield * config/rs6000/x-aix: Increase memory limit for genautomata on AIX. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 96faffd81e8..5b27b8d1f6f 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -37752,98 +37752,82 @@ rdseed_step: case IX86_BUILTIN_KTESTC8: icode = CODE_FOR_ktestqi; - mode0 = QImode; - mode1 = CCCmode; + mode3 = CCCmode; goto kortest; case IX86_BUILTIN_KTESTZ8: icode = CODE_FOR_ktestqi; - mode0 = QImode; - mode1 = CCZmode; + mode3 = CCZmode; goto kortest; case IX86_BUILTIN_KTESTC16: icode = CODE_FOR_ktesthi; - mode0 = HImode; - mode1 = CCCmode; + mode3 = CCCmode; goto kortest; case IX86_BUILTIN_KTESTZ16: icode = CODE_FOR_ktesthi; - mode0 = HImode; - mode1 = CCZmode; + mode3 = CCZmode; goto kortest; case IX86_BUILTIN_KTESTC32: icode = CODE_FOR_ktestsi; - mode0 = SImode; - mode1 = CCCmode; + mode3 = CCCmode; goto kortest; case IX86_BUILTIN_KTESTZ32: icode = CODE_FOR_ktestsi; - mode0 = SImode; - mode1 = CCZmode; + mode3 = CCZmode; goto kortest; case IX86_BUILTIN_KTESTC64: icode = CODE_FOR_ktestdi; - mode0 = DImode; - mode1 = CCCmode; + mode3 = CCCmode; goto kortest; case IX86_BUILTIN_KTESTZ64: icode = CODE_FOR_ktestdi; - mode0 = DImode; - mode1 = CCZmode; + mode3 = CCZmode; goto kortest; case IX86_BUILTIN_KORTESTC8: icode = CODE_FOR_kortestqi; - mode0 = QImode; - mode1 = CCCmode; + mode3 = CCCmode; goto kortest; case IX86_BUILTIN_KORTESTZ8: icode = CODE_FOR_kortestqi; - mode0 = QImode; - mode1 = CCZmode; + mode3 = CCZmode; goto kortest; case IX86_BUILTIN_KORTESTC16: icode = CODE_FOR_kortesthi; - mode0 = HImode; - mode1 = CCCmode; + mode3 = CCCmode; goto kortest; case IX86_BUILTIN_KORTESTZ16: icode = CODE_FOR_kortesthi; - mode0 = HImode; - mode1 = CCZmode; + mode3 = CCZmode; goto kortest; case IX86_BUILTIN_KORTESTC32: icode = CODE_FOR_kortestsi; - mode0 = SImode; - mode1 = CCCmode; + mode3 = CCCmode; goto kortest; case IX86_BUILTIN_KORTESTZ32: icode = CODE_FOR_kortestsi; - mode0 = SImode; - mode1 = CCZmode; + mode3 = CCZmode; goto kortest; case IX86_BUILTIN_KORTESTC64: icode = CODE_FOR_kortestdi; - mode0 = DImode; - mode1 = CCCmode; + mode3 = CCCmode; goto kortest; case IX86_BUILTIN_KORTESTZ64: icode = CODE_FOR_kortestdi; - mode0 = DImode; - mode1 = CCZmode; + mode3 = CCZmode; kortest: arg0 = CALL_EXPR_ARG (exp, 0); /* Mask reg src1. */ @@ -37851,19 +37835,32 @@ rdseed_step: op0 = expand_normal (arg0); op1 = expand_normal (arg1); - op0 = copy_to_reg (op0); - op0 = lowpart_subreg (mode0, op0, GET_MODE (op0)); - op1 = copy_to_reg (op1); - op1 = lowpart_subreg (mode0, op1, GET_MODE (op1)); + mode0 = insn_data[icode].operand[0].mode; + mode1 = insn_data[icode].operand[1].mode; + + if (GET_MODE (op0) != VOIDmode) + op0 = force_reg (GET_MODE (op0), op0); + + op0 = gen_lowpart (mode0, op0); + + if (!insn_data[icode].operand[0].predicate (op0, mode0)) + op0 = copy_to_mode_reg (mode0, op0); + + if (GET_MODE (op1) != VOIDmode) + op1 = force_reg (GET_MODE (op1), op1); + + op1 = gen_lowpart (mode1, op1); + + if (!insn_data[icode].operand[1].predicate (op1, mode1)) + op1 = copy_to_mode_reg (mode1, op1); target = gen_reg_rtx (QImode); - emit_insn (gen_rtx_SET (target, const0_rtx)); /* Emit kortest. */ emit_insn (GEN_FCN (icode) (op0, op1)); /* And use setcc to return result from flags. */ ix86_expand_setcc (target, EQ, - gen_rtx_REG (mode1, FLAGS_REG), const0_rtx); + gen_rtx_REG (mode3, FLAGS_REG), const0_rtx); return target; case IX86_BUILTIN_GATHERSIV2DF: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f36569c31fa..828d82daac1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-06 Uros Bizjak + + PR target/79733 + * gcc.target/i386/pr79733.c: New test. + 2017-04-06 Uros Bizjak PR target/80298 diff --git a/gcc/testsuite/gcc.target/i386/pr79733.c b/gcc/testsuite/gcc.target/i386/pr79733.c new file mode 100644 index 00000000000..5caec911b01 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr79733.c @@ -0,0 +1,23 @@ +/* PR target/79733 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512f" } */ + +typedef unsigned short __mmask16; + +extern __inline int +__attribute__ ((__gnu_inline__, __always_inline__, __artificial__)) +_mm512_kortestc (__mmask16 __A, __mmask16 __B) +{ + return (__mmask16) __builtin_ia32_kortestchi ((__mmask16) __A, + (__mmask16) __B); +} + +void +avx512f_test () +{ + volatile __mmask16 k1 = 0; + __mmask16 k2 = 0; + volatile short r; + + r = _mm512_kortestc (k1, k2); +} -- 2.30.2