From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by sourceware.org (Postfix) with ESMTPS id 9DC8B397201A; Wed, 14 Jul 2021 05:13:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9DC8B397201A Received: by mail-vs1-xe33.google.com with SMTP id j2so279425vsi.6; Tue, 13 Jul 2021 22:13:46 -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:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9E0UqzS8YX0r2hDhMy1ebEltus1WE7ZjyjmnX0FJa8A=; b=rOuGyl6wfmIdbcApKg279uGQizgz7+G4fby2TAaEDylVqo5w+RZUCzfSGIfnHp+gaU 1oS2dycJra22gZR9MmaxGwGoggjWS4Be8LVRuwSs9xYPcAfJBIqTeeixVbMlutckKO4L i6yI51ihph3DrcDBvN536gI/11XUtzjskDqTAEIOVfk6aqN59sRpiWv2/7SfIhx/Dy/h 3nNXFS+HwOmuz5Nk/7P9+funArLe6vYHfdE3jXwPktCdB+DuvFORJKR4sEAUMYguxXJx gYVO1tIfviSIF1Z5RxYVTEXuRvVDMIAkVQOyqDwR/HgwSNQgc8oD/3f2GDNmoVt2K57Q pliA== X-Gm-Message-State: AOAM533A0+pBDLvltIf9vP0GfdWtcsnvty36jKaBIZd3Uw4YJFHoFX3g 5484hRxGDyjoWw6rwXPzreUrQz4cuAACYJ4/MKZJtS/E89LRBQ== X-Google-Smtp-Source: ABdhPJxJ0xxjlYjwhZgP/uBqmuQGCJBZaLjEckdSBSn5CRHHkk9JfOgRJ8JdV15Jz5lRLWaKM2aUeX7dwuUeriS/tis= X-Received: by 2002:a67:1787:: with SMTP id 129mr11153857vsx.57.1626239626140; Tue, 13 Jul 2021 22:13:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Hongtao Liu Date: Wed, 14 Jul 2021 13:18:29 +0800 Message-ID: Subject: Re: [Questions] Is there any bit in gimple/rtl to indicate this IR support fast-math or not? To: gcc-help@gcc.gnu.org, GCC Patches , GCC Development Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jul 2021 05:13:49 -0000 On Wed, Jul 14, 2021 at 1:15 PM Hongtao Liu wrote: > > Hi: > The original problem was that some users wanted the cmdline option > -ffast-math not to act on intrinsic production code. .i.e for codes > like > > #include > __m256d > foo2 (__m256d a, __m256d b, __m256d c, __m256d d) > { > __m256d tmp = _mm256_add_pd (a, b); > tmp = _mm256_sub_pd (tmp, c); > tmp = _mm256_sub_pd (tmp, d); > return tmp; > } > > compiled with -O2 -mavx2 -ffast-math, users expected codes generated like > > vaddpd ymm0, ymm0, ymm1 > vsubpd ymm0, ymm0, ymm2 > vsubpd ymm0, ymm0, ymm3 > > but not > > vsubpd ymm1, ymm1, ymm2 > vsubpd ymm0, ymm0, ymm3 > vaddpd ymm0, ymm1, ymm0 > > > For the LLVM side, there're mechanisms like > #pragma float_control( precise, on, push) > ...(intrinsics definition).. > #pragma float_control(pop) > > When intrinsics are inlined, their IRs will be marked with > "no-fast-math", and even if the caller is compiled with -ffast-math, > reassociation only happens to those IRs which are not marked with > "no-fast-math". It seems to be more flexible to support fast math > control of a region(inside a function). Testcase https://godbolt.org/z/9cYMGGWPG > > Does GCC have a similar mechanism? > > > -- > BR, > Hongtao -- BR, Hongtao