From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19480 invoked by alias); 21 Jun 2018 11:42:46 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 19468 invoked by uid 89); 21 Jun 2018 11:42:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*i:sk:17623B1, H*f:sk:17623B1, Question X-HELO: mail-yw0-f170.google.com Received: from mail-yw0-f170.google.com (HELO mail-yw0-f170.google.com) (209.85.161.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Jun 2018 11:42:44 +0000 Received: by mail-yw0-f170.google.com with SMTP id g123-v6so682959ywf.13 for ; Thu, 21 Jun 2018 04:42:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CTCXE3bdkd3hb3Lg4j4v2ZSSovPER32xeir5Wvt2Dq8=; b=V09QYPDN/cAuMHMDvqfm+mXFjhE9BR3/LW7Gl2SA4BbGYbr7RLlx38gLpaoBlXtkVu 3R4E/5U/x0+MnPuVmqcfgQ2lVyuUJlwFt1MJqdSFfk1FeNPeDXeG5yVCgpPAz4DYc6st oFs1vxg/1l4fNTXfj6qRkRMD57Lvtp6MqDazTjp0cvAjaUymNZF+l0/DRZ5ep3ulFnYp uhh637DUUz+6MZfCt1xpE0yQgiHmnVBlYZFarRZb6Ogu13Ht3WivMSUY91bxARIuw80L NzKruAVTyeeUv6J51tt+W7vduoO/wMtMmzf801NmjVhKsyEriZnIZGtjYjpLDSNQu1zP DHbQ== X-Gm-Message-State: APt69E0AY34+AClKTY+aB2kNxrNUf7qa4FOaWxxXP1ul0zmz97+4uKiY oiM/F+ROpf5Jc2OjISObbBI= X-Google-Smtp-Source: ADUXVKIxJ+lQrxcvN9m52UsMGXF2G9B5ctL+e4bJjdxnHPr7WZpr3QRrQlcVJHKqkT9aETacE3bRTg== X-Received: by 2002:a0d:ef46:: with SMTP id y67-v6mr12092672ywe.51.1529581363004; Thu, 21 Jun 2018 04:42:43 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3:1c8e]) by smtp.googlemail.com with ESMTPSA id v72-v6sm1729564ywg.25.2018.06.21.04.42.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 04:42:42 -0700 (PDT) Subject: Re: Question regarding preventing optimizing out of register in expansion To: "Peryt, Sebastian" , "gcc@gcc.gnu.org" References: <17623B198193D741876BD81A6E3AE5AD3C7B98EE@irsmsx111.ger.corp.intel.com> From: Nathan Sidwell Message-ID: <568618ea-c8e3-c44a-5b48-89a8623bc29d@acm.org> Date: Thu, 21 Jun 2018 13:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <17623B198193D741876BD81A6E3AE5AD3C7B98EE@irsmsx111.ger.corp.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2018-06/txt/msg00232.txt.bz2 On 06/21/2018 05:20 AM, Peryt, Sebastian wrote: > Hi, > > I'd appreciate if someone could advise me in builtin expansion I'm currently writing. > > High level description for what I want to do: > > I have 2 operands in my builtin. IIUC you're defining an UNSPEC. > First I set register (reg1) with value from operand1 (op1); > Second I call my instruction (reg1 is called implicitly and updated); Here is your error -- NEVER have implicit register settings. The data flow analysers need accurate information. > Simplified implementation in i386.c I have: > > reg1 = gen_reg_rtx (mode); > emit_insn (gen_rtx_SET (reg1, op1); > emit_clobber (reg1); At this point reg1 is dead. That means the previous set of reg1 from op1 is unneeded and can be deleted. > emit_insn (gen_myinstruction ()); This instruction has no inputs or outputs, and is not marked volatile(?) so can be deleted. > emit_insn (gen_rtx_SET (op2,reg1)); And this is storing a value from a dead register. You need something like: rtx reg1 = force_reg (op1); rtx reg2 = gen_reg_rtx (mode); emit_insn (gen_my_insn (reg2, reg1)); emit insn (gen_rtx_SET (op2, reg2)); your instruction should be an UNSPEC showing what the inputs and outputs are. That tells the optimizers what depends on what, but the compiler has no clue about what the transform is. nathan -- Nathan Sidwell