From patchwork Wed Oct 10 09:09:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 981766 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-487241-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="dw2FHV7A"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42VTB03n6wz9s8r for ; Wed, 10 Oct 2018 20:21:27 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=lk8U7JOGB54e9nclAwzc/6oSfjAa5 qRYIMPKfytFdwwEzbr0s9jaP/3ScVJISVi+V7w9IemPGv+gM1/LCJ7QUrCj7JA+P iUD31qsM2eS7FsoU1djUXpII4sbLIjlHfPONDABggAqOiQoDKAWUena/cwmsmtMu huzk7BGGQG8s60= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=EMlx6YzH8coZIbAv0k/+SBi38Hg=; b=dw2 FHV7AxRehk2lLSJvUcl+520eCQ5ZylU1Z2uBZXycWgJOkC/GprQrB7CZfB6LKErx xDVhYjm5xv0l5rrkSeYDu4C98UWx9em+veHhXkbakl2vWL+cBNO/6IZggKMraYtx hlUKfyCFUm9sGaIkNiPcdkVCT0+aynx4887poqBc= Received: (qmail 30400 invoked by alias); 10 Oct 2018 09:09:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 29694 invoked by uid 89); 10 Oct 2018 09:09:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=87550 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Oct 2018 09:09:13 +0000 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D3AFE8CD0; Wed, 10 Oct 2018 09:09:11 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-222.ams2.redhat.com [10.36.117.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C1721001942; Wed, 10 Oct 2018 09:09:11 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id w9A998mW009795; Wed, 10 Oct 2018 11:09:09 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id w9A998fh009794; Wed, 10 Oct 2018 11:09:08 +0200 Date: Wed, 10 Oct 2018 11:09:07 +0200 From: Jakub Jelinek To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix __builtin_ia32_rdpmc (PR target/87550) Message-ID: <20181010090907.GS11625@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! The following testcase shows that we incorrectly handle __builtin_ia32_rdpmc as a const function, so we e.g. CSE it. The problem is that all bdesc_args functions are registered using def_builtin_const. The patch fixes this by moving it to the bdesc_special_args category, which is registered with def_builtin, similarly to e.g. rdtsc builtin. The expansion is handled specially before we decide whether to call args or special_args expansion, and doesn't fall through, so from that POV it doesn't really matter which category it is. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-10-10 Jakub Jelinek PR target/87550 * config/i386/i386-builtin.def (IX86_BUILTIN_RDPMC): Move from args set to special_args set. * gcc.target/i386/pr87550.c: New test. Jakub --- gcc/config/i386/i386-builtin.def.jj 2018-06-13 10:05:54.816128362 +0200 +++ gcc/config/i386/i386-builtin.def 2018-10-09 09:28:10.199072944 +0200 @@ -90,6 +90,7 @@ BDESC_END (PCMPISTR, SPECIAL_ARGS) BDESC_FIRST (special_args, SPECIAL_ARGS, 0, CODE_FOR_nothing, "__builtin_ia32_rdtsc", IX86_BUILTIN_RDTSC, UNKNOWN, (int) UINT64_FTYPE_VOID) BDESC (0, CODE_FOR_nothing, "__builtin_ia32_rdtscp", IX86_BUILTIN_RDTSCP, UNKNOWN, (int) UINT64_FTYPE_PUNSIGNED) +BDESC (0, CODE_FOR_nothing, "__builtin_ia32_rdpmc", IX86_BUILTIN_RDPMC, UNKNOWN, (int) UINT64_FTYPE_INT) BDESC (0, CODE_FOR_pause, "__builtin_ia32_pause", IX86_BUILTIN_PAUSE, UNKNOWN, (int) VOID_FTYPE_VOID) /* 80387 (for use internally for atomic compound assignment). */ @@ -427,7 +428,6 @@ BDESC_END (SPECIAL_ARGS, ARGS) BDESC_FIRST (args, ARGS, 0, CODE_FOR_bsr, "__builtin_ia32_bsrsi", IX86_BUILTIN_BSRSI, UNKNOWN, (int) INT_FTYPE_INT) BDESC (OPTION_MASK_ISA_64BIT, CODE_FOR_bsr_rex64, "__builtin_ia32_bsrdi", IX86_BUILTIN_BSRDI, UNKNOWN, (int) INT64_FTYPE_INT64) -BDESC (0, CODE_FOR_nothing, "__builtin_ia32_rdpmc", IX86_BUILTIN_RDPMC, UNKNOWN, (int) UINT64_FTYPE_INT) BDESC (0, CODE_FOR_rotlqi3, "__builtin_ia32_rolqi", IX86_BUILTIN_ROLQI, UNKNOWN, (int) UINT8_FTYPE_UINT8_INT) BDESC (0, CODE_FOR_rotlhi3, "__builtin_ia32_rolhi", IX86_BUILTIN_ROLHI, UNKNOWN, (int) UINT16_FTYPE_UINT16_INT) BDESC (0, CODE_FOR_rotrqi3, "__builtin_ia32_rorqi", IX86_BUILTIN_RORQI, UNKNOWN, (int) UINT8_FTYPE_UINT8_INT) --- gcc/testsuite/gcc.target/i386/pr87550.c.jj 2018-10-09 09:36:33.470600220 +0200 +++ gcc/testsuite/gcc.target/i386/pr87550.c 2018-10-09 09:37:30.384642051 +0200 @@ -0,0 +1,21 @@ +/* PR target/87550 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +#include + +int +foo (int x) +{ + return __rdtsc () + __rdtsc (); +} + +/* { dg-final { scan-assembler-times "\trdtsc\[\n\r]" 2 } } */ + +int +bar (int x) +{ + return __rdpmc (0) + __rdpmc (0); +} + +/* { dg-final { scan-assembler-times "\trdpmc\[\n\r]" 2 } } */