From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by sourceware.org (Postfix) with ESMTPS id 984EB3858C2C for ; Wed, 30 Nov 2022 02:03:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 984EB3858C2C 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-yb1-xb33.google.com with SMTP id v206so3135944ybv.7 for ; Tue, 29 Nov 2022 18:03:48 -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=I3/KMVVsTQb+YwF2ijC511mCXeN2DWS6B5PRVbSlYu4=; b=bmCjGjxnaU0DM8SDYv6XgWGBlxpRSaMQI1xHZXhEdSsENMyMCmO/BtphITtyM4ccND Tz5923Go1UVCBtGUnGdqUvlY1Xxm6AS7eWx/1c7H2fNwdFD+hloOC3IDjmTnV8JN75TW Tk24NS/xGP2BinB1Bum3s8I5g15X4Ts3AUuuY6y9fN9zHtDfYOkqyJukSNC8G1Y9txRy /eLYAjZT4SmSvELo2fFRj4UqSx2Z1gKzeOGw3Qkj4xIC6nKkURYXGsAfxuFgRh8JXAGO EsHOyjRIX/Zw/H/OQMb3yy5FXWL438yStxOZFCf3sc9Yj8SCp9QE01IYdyZ5jSUn+WJo OoOw== 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=I3/KMVVsTQb+YwF2ijC511mCXeN2DWS6B5PRVbSlYu4=; b=WNeyOXtmHB9MVt5l8mNRoXXLon0wwmnfy8ziZ7YORaUfg7BT8wINCHhLlE5V7bB2SO wfX9iYq6H7pZjZfnTM7mv94lRRfsOAZmuO4kfXvEPTGmhqFdeJfDYHv/wgginT9zslcz I+E3+F0eb2Ekf2hhsOg80IdtqIMwHOGHKXZ4rnL5s9Gsb+gnkbIMGrG4qLMzeEQtnXoj y/oTOcK1Qcf9Ck6GXkayb2z0EUW+eDy7dIETX3ZHD3vjOXScc9vU4RyEvwK61JgEolEa ChtLz9AvdKcZIwKr49W7i097YzOC1Yoc7UvB2F4Bl0oV4YJnCZ6FT3B8dAiAutWQIvZM tvLw== X-Gm-Message-State: ANoB5pkOt3gPeAM5q02dq70LDrPpk1LJ50HwU1PxwdacuASZifpxEXhI D9yVnlZ2dwpcv5mkEFzZ+hEXPt5FDeh3tg2fvdY= X-Google-Smtp-Source: AA0mqf5Q7tfaciWfXF1gfvBcC8WaJUVVSPM642t8Iz9VYL/yM8QeoJ5URts83viKbip4p002QoKHtOUVqJKNBzwBI5Y= X-Received: by 2002:a25:7343:0:b0:6f3:aedd:e75 with SMTP id o64-20020a257343000000b006f3aedd0e75mr22265494ybc.611.1669773827606; Tue, 29 Nov 2022 18:03:47 -0800 (PST) MIME-Version: 1.0 References: <20221128130539.2124727-1-hongtao.liu@intel.com> In-Reply-To: From: Hongtao Liu Date: Wed, 30 Nov 2022 10:03:36 +0800 Message-ID: Subject: Re: [PATCH] [x86] Fix unrecognizable insn due to illegal immediate_operand (const_int 255) of QImode. To: "H.J. Lu" Cc: liuhongt , gcc-patches@gcc.gnu.org, ubizjak@gmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 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 Wed, Nov 30, 2022 at 3:12 AM H.J. Lu wrote: > > On Mon, Nov 28, 2022 at 11:04 PM Hongtao Liu wrote: > > > > 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. > > I checked the x86 backend. __builtin_ia32_vec_set_v16qi is the > only intrinsic with this issue. Ok, I'll commit the patch. > > > > > > > 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 > > > > -- > H.J. -- BR, Hongtao