From patchwork Thu May 20 06:58:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongtao Liu X-Patchwork-Id: 1481379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=OYLd4O1x; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fm0pb6X7Xz9sfG for ; Thu, 20 May 2021 16:54:30 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9A490394FC02; Thu, 20 May 2021 06:54:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A490394FC02 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1621493668; bh=AFGztevRmNnCFK5hs2kMiVc3sS26G0YIL75zc6pckOQ=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OYLd4O1xQQvM4IC2v+mSaq553XE5pMkmzXD1Vz5NMPIHuPIY+wbpbhaEFqP9+pwtC Lo76P2xKG865jczMDZE1pDzgFTKfM4pH3alUI58r/ViXa4faR2ZQ6Jj0fTPSxAR1QZ P2Z+8AACshQIhawo6/CeQOgDuZSNLbRE4PYm76Ew= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-vs1-xe35.google.com (mail-vs1-xe35.google.com [IPv6:2607:f8b0:4864:20::e35]) by sourceware.org (Postfix) with ESMTPS id 2CFCC394D8FE for ; Thu, 20 May 2021 06:54:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2CFCC394D8FE Received: by mail-vs1-xe35.google.com with SMTP id s15so8022920vsi.4 for ; Wed, 19 May 2021 23:54:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=AFGztevRmNnCFK5hs2kMiVc3sS26G0YIL75zc6pckOQ=; b=e52u8HNj4OHZEJqrXMAo/dIjwhuN3MxB4q1UZ1FkdPiJYPMm2gQOpLKwPQetG4oVwI ejVvAlM2UOk0hP7DVVzKtmO4DYLttZE+jDfkjwkrta33xZCO5m4s+DSli0ybtz3kpBB3 2GtEbm4KyBRCAlHIG6Pg1MqlGy87QTVaSgt7Xi8aPZE/WK8kFJrsKSy8hV7/5pUsJgli 490STa7Y5QAZ/lsaKauJkyPLIzl4vdkZkxO8pYCZ5iZXDUlGU+OTub5htetd4xS3ciOG Cn6C+R+dUVT8dSXtGcMuYrY6cA3NgQFwDIDcVj/DDarmGWDSKwaNzyM2hoShpfoLriuW rcrg== X-Gm-Message-State: AOAM53205/9y2uvF28qfJ9omdGYWQrS27eWoFovmnF2JZcFI5cmuIu5V 92OlraJb5Z6VnfWSaduOtko32fbE7wt/7n+IZmw= X-Google-Smtp-Source: ABdhPJxT+h2qzL8k/yKNaP/2jbgNrvr3NKSsT51mYU0G2CQSK7LYjRV2ysYqJNSWVwss0ez9OP1+Cp98SDfEdkkIOrg= X-Received: by 2002:a05:6102:2331:: with SMTP id b17mr2354037vsa.57.1621493665824; Wed, 19 May 2021 23:54:25 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 20 May 2021 14:58:37 +0800 Message-ID: Subject: [i386] [PATCH] Fix ICE when lhs is NULL [PR target/100660] To: Richard Biener , GCC Patches X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Hongtao Liu via Gcc-patches From: Hongtao Liu Reply-To: Hongtao Liu Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi: In folding target-specific builtin, when lhs is NULL, create a temporary variable for it. Bootstrapped and regtested on x86_64-linux-gnu{-m32,} gcc/ChangeLog: PR target/100660 * config/i386/i386.c (ix86_gimple_fold_builtin): Create a tmp variable for lhs when it doesn't exist. gcc/testsuite/ChangeLog: PR target/100660 * gcc.target/i386/pr100660.c: New test. From b32791645429e3e25c46f56e2b81ffab7863afde Mon Sep 17 00:00:00 2001 From: liuhongt Date: Thu, 20 May 2021 09:59:36 +0800 Subject: [PATCH] Fix ICE when lhs is NULL. gcc/ChangeLog: PR target/100660 * config/i386/i386.c (ix86_gimple_fold_builtin): Create a tmp variable for lhs when it doesn't exist. gcc/testsuite/ChangeLog: PR target/100660 * gcc.target/i386/pr100660.c: New test. --- gcc/config/i386/i386.c | 5 ++++- gcc/testsuite/gcc.target/i386/pr100660.c | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr100660.c diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 743d8a25fe3..705257c414f 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -18000,7 +18000,10 @@ ix86_gimple_fold_builtin (gimple_stmt_iterator *gsi) gimple_seq stmts = NULL; tree cmp = gimple_build (&stmts, tcode, cmp_type, arg0, arg1); gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); - gimple* g = gimple_build_assign (gimple_call_lhs (stmt), + tree lhs = gimple_call_lhs (stmt); + if (!lhs) + lhs = create_tmp_reg_or_ssa_name (type); + gimple* g = gimple_build_assign (lhs, VEC_COND_EXPR, cmp, minus_one_vec, zero_vec); gimple_set_location (g, loc); diff --git a/gcc/testsuite/gcc.target/i386/pr100660.c b/gcc/testsuite/gcc.target/i386/pr100660.c new file mode 100644 index 00000000000..1112b742779 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr100660.c @@ -0,0 +1,10 @@ +/* PR target/pr100660. */ +/* { dg-do compile } */ +/* { dg-options "-mavx2 -O" } */ + +typedef char v16qi __attribute__ ((vector_size (16))); +v16qi +f5 (v16qi a, v16qi b) +{ + __builtin_ia32_pcmpgtb128 (a, b); +} -- 2.18.1