From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 363113858D35 for ; Thu, 28 Oct 2021 10:54:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 363113858D35 Received: by mail-pf1-x430.google.com with SMTP id k26so5596043pfi.5 for ; Thu, 28 Oct 2021 03:54:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HqYe4Gm10xJmBtNGdba/UUjse6LMepiVkND1rCa0Nsc=; b=eemJcQYLakrL8mFwTVZhdMGe0KS9WOPFJJX/ooUIt/D9Wmj/n3ftlQHr2izxO+szN6 t9ZEbzf3pn78zfYYTQTg2BCHt2Y13+ExauIP2CLFHLJpppDxK1mgo9qRCqpjD54agg47 HMmphfEqRyUAMOspkG7QflyjcUyYK0krJjtIjnhZNCTyK4KstMSlvyHN/xQ42VyFX5X4 LurseR7cFYDASX7wmZiIwzHtddlP6mmH/h1XRdzohHwMbASCwo851VtAVnqfNrKA2J3e cVAyAMMytL7xgkWgCkJNn/j7Yb0ERLyzSh2fScyl4qgpGSB/jUQcNl+3Ki1Xa5VoHJKW 5U+Q== X-Gm-Message-State: AOAM5317eYm4fVdE9pxKxyXsz2IYDjPG2TRLNwjmJS1f/Fv498ktasDb iLeRw5uYIg8PURnxQqk1veqY8Jf2yUkqChhKKvA= X-Google-Smtp-Source: ABdhPJx/dBdVoEhaJCtuNvVYubchYMW8JUnLoGuCKw4Nm2a0AJvwz0Dh1RBM0cRz9UOfCmHVYxmOQIjD7lFrLRVtHcw= X-Received: by 2002:a63:ef57:: with SMTP id c23mr2600396pgk.60.1635418484143; Thu, 28 Oct 2021 03:54:44 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?4piCSm9zaCBDaGlhICjorJ3ku7vkuK0p?= Date: Thu, 28 Oct 2021 18:54:33 +0800 Message-ID: Subject: Re: Generated assembly code for returning std::optional To: Jonathan Wakely Cc: gcc-help X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Oct 2021 10:54:46 -0000 Yes, it is. Thanks. On Thu, Oct 28, 2021 at 5:55 PM Jonathan Wakely wrote: > On Thu, 28 Oct 2021 at 08:11, =E2=98=82Josh Chia (=E8=AC=9D=E4=BB=BB=E4= =B8=AD) via Gcc-help > wrote: > > > > Under -O3 -std=3Dc++17, the assembly code generated by gcc 11.2 for som= e > > std::optional C++ code seems less optimal than I expect; it is writing > the > > content of optional return values to both the stack and to th= e > > RAX register. What am I missing? I was under the impression that return > > values are put in RAX if they can fit. Why does gcc have to write the > > return value to both the stack and RAX instead of just one of them? Can > the > > writing to the stack be avoided? > > Is this https://gcc.gnu.org/PR101326 ? >