From patchwork Mon Mar 26 19:30:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 891191 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-475472-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CISdavm4"; 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 40944V61Bdz9s1p for ; Tue, 27 Mar 2018 06:30:50 +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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=VHj63q1y/07w5njTw6emiq2EPPLq5vbTcWDBgiGLQbtR/6 3nBrQXqs4ArNeVIjTjF/9d2V4HCZPVoxIRIcMKfbJxiUjttONe8I8RqABVrXa340 wabSsM123rnVU52mfEirzAhIgD44EzhCm80tqnggD61lUkbG3wSUpy2KQRMjk= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=qYe2zSHIUxIOWxiOK28YFTcxTWQ=; b=CISdavm4NxbB0gSVgdi0 Y08S0VBnOBNScrYobsqI+qv+bXNi5YUtNPMk7CdA/jK4UYBqm4KRp948dbb6rj75 4hZxWho0RjF6SnXOoBS5exN2E7tVgNn3l/kicPnIqjhb4NYV299kI4dhxcqfXupY sVVP6OdSgVwPpd0TCvWllEs= Received: (qmail 122050 invoked by alias); 26 Mar 2018 19:30:41 -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 108285 invoked by uid 89); 26 Mar 2018 19:30:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:nonimme X-HELO: mail-io0-f171.google.com Received: from mail-io0-f171.google.com (HELO mail-io0-f171.google.com) (209.85.223.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Mar 2018 19:30:20 +0000 Received: by mail-io0-f171.google.com with SMTP id v13so24629521iob.6 for ; Mon, 26 Mar 2018 12:30:18 -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=m5/eD3ZSRrSLnMh/CA3pIfiksHuXNDNKxpaU0qscq+I=; b=sNqk4StwBSsU6ifHQnPCv3+Wdg/mJNb9o1ersZ/YlHq1/93XOEwBWIThCHI/VH0K5J Xsl8OZkJo8+nQ8HHTRRz9oosb7a97cPuIk22Rx9XLu8WcnwdcQGr4FEvVq2BVhJMeyAH yfSVJudIgRbE6DJ/EY1+3smF5Yufy+zjO7yCLfngygpZo47OtStBTR/8CSUs681I7XJI pSbu9NSrbmgFH3lnfKGRJ6X2aZSwc4t6LPh42qukuSXc8iJgTQ0uVlhzMI5yZcvXqwgq Tz0S20AZUXR36sb8OMPmORyodFH1AkRtn0+wuzdU/yZCqxQRT9q0e7KFzwRsepjGZyOe BCAw== X-Gm-Message-State: AElRT7HtFI/DBylydcq1n6JMGuArNhVVFyVD2+7tQ3adTZc+kIjXPHlY vGosXewd5IBppNdRajg+TILIMoA6rPcP3M4NqODTrw== X-Google-Smtp-Source: AG47ELvYqYGH5t5X3rCB44HS+YMneMDDac9tKV8aZ7P8pCFM9PDJQQGL5Fo8Azmh7nYJkiR7N6MXyJPenG1mfec3KKE= X-Received: by 10.107.18.22 with SMTP id a22mr38822140ioj.190.1522092616301; Mon, 26 Mar 2018 12:30:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.136.205 with HTTP; Mon, 26 Mar 2018 12:30:15 -0700 (PDT) From: Uros Bizjak Date: Mon, 26 Mar 2018 21:30:15 +0200 Message-ID: Subject: [PATCH, i386]: Fix PR 85073: extra check after BLSR To: "gcc-patches@gcc.gnu.org" 2018-03-26 Uros Bizjak PR target/85073 * config/i386/i386.md (*bmi_blsr__cmp): New insn pattern. (*bmi_blsr__ccz): Ditto. testsuite/ChangeLog: 2018-03-26 Uros Bizjak PR target/85073 * gcc.target/i386/pr85073.c: New test. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros. Index: config/i386/i386.md =================================================================== --- config/i386/i386.md (revision 258856) +++ config/i386/i386.md (working copy) @@ -13774,6 +13774,43 @@ (set_attr "btver2_decode" "double") (set_attr "mode" "")]) +(define_insn "*bmi_blsr__cmp" + [(set (reg:CCZ FLAGS_REG) + (compare:CCZ + (and:SWI48 + (plus:SWI48 + (match_operand:SWI48 1 "nonimmediate_operand" "rm") + (const_int -1)) + (match_dup 1)) + (const_int 0))) + (set (match_operand:SWI48 0 "register_operand" "=r") + (and:SWI48 + (plus:SWI48 + (match_dup 1) + (const_int -1)) + (match_dup 1)))] + "TARGET_BMI" + "blsr\t{%1, %0|%0, %1}" + [(set_attr "type" "bitmanip") + (set_attr "btver2_decode" "double") + (set_attr "mode" "")]) + +(define_insn "*bmi_blsr__ccz" + [(set (reg:CCZ FLAGS_REG) + (compare:CCZ + (and:SWI48 + (plus:SWI48 + (match_operand:SWI48 1 "nonimmediate_operand" "rm") + (const_int -1)) + (match_dup 1)) + (const_int 0))) + (clobber (match_scratch:SWI48 0 "=r"))] + "TARGET_BMI" + "blsr\t{%1, %0|%0, %1}" + [(set_attr "type" "bitmanip") + (set_attr "btver2_decode" "double") + (set_attr "mode" "")]) + ;; BMI2 instructions. (define_expand "bmi2_bzhi_3" [(parallel Index: testsuite/gcc.target/i386/pr85073.c =================================================================== --- testsuite/gcc.target/i386/pr85073.c (nonexistent) +++ testsuite/gcc.target/i386/pr85073.c (working copy) @@ -0,0 +1,18 @@ +/* PR target/85073 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mbmi" } */ + +int +foo (unsigned x) +{ + int c = 0; + while (x) + { + c += 1; + x = (x - 1) & x; + } + + return c; +} + +/* { dg-final { scan-assembler-times "test" 1 } } */