From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by sourceware.org (Postfix) with ESMTPS id 7558238532ED for ; Tue, 29 Nov 2022 07:04:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7558238532ED Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-3b10392c064so130180527b3.0 for ; Mon, 28 Nov 2022 23:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8skcWBvt53qr2Oj1X3NA+HdQHFEw98hM/R5gfmYWWzY=; b=Nu1DDTqw/JgCvX/QJAJR9xZqxodxZQjQZ2LHB9iH7VsO/ntsBloUrgb/cMFMrZfT1n l8taOnHvN+xDhCRHrPemxOALkwHIDjb3gAExSiftACiKWKvTTo0++KlVanPiREOJOf9l qD8cEqLbiE8jsf/YTJKB0yy9CxZE86/JbcA4FuZcqZzaihg3ZYcs0MaJr0CJYwoucNo6 Gkf6H4rBB/DiK15lAhXOHxRnYERLjA6aRqKxvUx9i2A+NzGFsj+ei6x1SkVZtkm0wsGV cy5eXnhV/RZaD5wHcdcuAgQEp5ia7+/e9LVbm0OCfC4umASWWAgJmrx8TnFX/kg+aa82 cAqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8skcWBvt53qr2Oj1X3NA+HdQHFEw98hM/R5gfmYWWzY=; b=Rq4rowi7rpQu8txVCFmt+LdgGJM0IqHrFvLY02SxjGvAXQmPPI4Zkm0LOLLIlMTakE +J7iZFOnYV8aC5dbVZ7JaXoNagGQh8NtWiY6tDHlFMzHZsxHR6fj/3c9RcnbbwoHjTNR 3q0AEBsz0zpKCsV2YlEIuCVTqCRlWewz1MVd46TAvaJrYu6G7FsSTcON0Q/9KILABPw2 50xSVFbSI1FLn727Gt7ZAAVJ0GHTk1nPmcDbP4Gvd1Ww+qz+HIwM65dlz1kDWYgwltVf ngSGW1XS5OtXPqkorHMqfKhtPxTUGnf9ofkr7TCSEtPsJJ8cjNwIakDC4ytGgZBxsvK/ bQ2A== X-Gm-Message-State: ANoB5pkN9U3aMhmOtFq10MrdBnV85Pl90sDE10y0UphWj1ikoMHtBF6p hMRa/BQNWYVKHJ7Hj4uGuKlLJY4vvbXq206mtEQ= X-Google-Smtp-Source: AA0mqf7+lkkUhzpMxZ2TDXTaQHcMKYNJOTzIanONHcwhZnN5pwt75HO9COif8mWH7tPqpqCkNse3M9bZAW7KNcQeJ4M= X-Received: by 2002:a81:9ad4:0:b0:3cf:4912:e7ab with SMTP id r203-20020a819ad4000000b003cf4912e7abmr2311620ywg.508.1669705485785; Mon, 28 Nov 2022 23:04:45 -0800 (PST) MIME-Version: 1.0 References: <20221128130539.2124727-1-hongtao.liu@intel.com> In-Reply-To: <20221128130539.2124727-1-hongtao.liu@intel.com> From: Hongtao Liu Date: Tue, 29 Nov 2022 15:04:34 +0800 Message-ID: Subject: Re: [PATCH] [x86] Fix unrecognizable insn due to illegal immediate_operand (const_int 255) of QImode. To: liuhongt Cc: gcc-patches@gcc.gnu.org, hjl.tools@gmail.com, ubizjak@gmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Nov 28, 2022 at 9:06 PM liuhongt wrote: > > 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. > > expand_expr_real_1 generates (const_int 255) without considering the target mode. > I guess it's on purpose, so I'll leave that alone and only change the expander > in the backend. After applying convert_modes to (const_int 255), > it's transformed to (const_int -1) which fix the issue. > > Bootstrapped and regtested x86_64-pc-linux-gnu{-m32,}. > Ok for trunk(and backport to GCC-10/11/12 release branches)? Drop this patch since it's not a complete solution, there're also other QI builtins which is not handled. > > 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 | 2 +- > gcc/testsuite/gcc.target/i386/pr107863.c | 8 ++++++++ > 2 files changed, 9 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.target/i386/pr107863.c > > diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc > index 0373c3614a4..c639ee3a9f7 100644 > --- a/gcc/config/i386/i386-expand.cc > +++ b/gcc/config/i386/i386-expand.cc > @@ -12475,7 +12475,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 > index 00000000000..99fd85d9765 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr107863.c > @@ -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); > +} > -- > 2.27.0 > -- BR, Hongtao