From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id E01DF3858D39 for ; Mon, 20 Dec 2021 21:54:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E01DF3858D39 Received: by mail-pg1-x534.google.com with SMTP id r138so10502553pgr.13 for ; Mon, 20 Dec 2021 13:54:27 -0800 (PST) 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=aHTLL2AFVLUKXOkPEgoNlTFdw7qsERw0xUTxaMWP130=; b=2JxkRK1HRT8UvGNghxsszOiK03M1NkM+YhT6V5tP9EW7gNHsMp42ykOdU3FontPY5o zqcKzBrH+A06TCmKKujzrzRbnwSLd8s4JlJ+FPtV+iisarMq0NGQ7OMKiU9tSvndvbke ii+3WRECQx4Db73J5Q9Iq2ApkNWemYozfrlA60X5N5i6zQ6n5XYIrX1NHHS4ZGYQaiXN Nr9T2GQ1pMFWKSKqoKEVTWZ0I25uZjGPJCiqvcit2hAyD7IjzeJJ1pfYZQphq9qr/9We TBWtJ36kk1j2sxuXZm79PUwlF8ZJNydaHOsvmrlHOIl90AUhtYgmUMxhLUQzt6vzxBje Qu4w== X-Gm-Message-State: AOAM530uaOYV+vrMJnVOYRMoyP9bAFa+zPuvncvCptzKEknmI8GvRjuK jOJ0MdJl8Hht+Omg8Y7m40SYwV5y0iyt/o5q8YE= X-Google-Smtp-Source: ABdhPJxkyKj9soMw60DhLqjlQ1T5wxdcBgtgUjxfWug87O02nkSYNDSTdviHP0YhXCdZNkMW9YcPmsCQ96pVGhjXpVs= X-Received: by 2002:a63:2166:: with SMTP id s38mr81992pgm.125.1640037267033; Mon, 20 Dec 2021 13:54:27 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "H.J. Lu" Date: Mon, 20 Dec 2021 13:53:51 -0800 Message-ID: Subject: Re: GCC 12 miscompiles libm To: Joseph Myers Cc: GNU C Library , Richard Biener Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3022.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Dec 2021 21:54:29 -0000 On Mon, Dec 20, 2021 at 1:49 PM Joseph Myers wrote: > > On Mon, 20 Dec 2021, H.J. Lu via Libc-alpha wrote: > > > Hi, > > > > GCC 12 miscompiles libm: > > > > https://sourceware.org/bugzilla/show_bug.cgi?id=28713 > > > > due to the fix for > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57245 > > > > which changes the behavior of -frounding-math on > > conversion from constant double and integer to float. > > However float codes in libm compiled with -frounding-math > > depend on the previous behavior in GCC 11. I added this > > to the glibc 2.35 blocker list. > > > > Joseph, Richard, do you have any suggestions how > > to fix it? > > 1. What specific constant conversion from double to float in the source > code is changed with GCC 12 so that it now occurs at runtime? > > 2. Does that conversion get executed in the abstract machine in the qNaN > path through the function (given that the test failures you report are for > qNaN inputs, and I'd generally expect those only to do arithmetic with > qNaN operands)? > > 3. If it does get executed in the abstract machine, why? It might well be > better to change the functions not to execute the conversion in that case. > > 4. Alternatively, maybe the conversion doesn't get executed in the > abstract machine in the qNaN path through the function, but the compiler > scheduled it to occur unconditionally because it doesn't model the side > effects of raising exceptions from the conversion. > > 5. Whether or not the conversion gets executed in the abstract machine, in > any case where a double constant in the source code is immediately > converted to float, it probably makes sense to change the source code to > use a corresponding float constant instead, and so avoid the runtime > conversion (unless the code actually expects a rounding-mode-dependent > result or an exception at runtime). > > 6. If M_* constants are involved, I suppose we need to add corresponding > float macros. I don't have answers to these questions. After I reverted the -frounding-math change in GCC 12, all libm tests passed. -- H.J.