From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 0DEF93858C56 for ; Wed, 12 Oct 2022 21:44:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0DEF93858C56 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x62e.google.com with SMTP id sc25so34598618ejc.12 for ; Wed, 12 Oct 2022 14:44:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=vpauSbDUiXOwVp8Xv14le33bjVkV/5/lAUr4AGJG7ek=; b=UCqTavt/YTjajLJvqHGMZNgj7qfdYCFOtxhmFBSJ8N/d5KtgPL02tL3/8PyibXIZj8 Cw1rNLWsXYIdGswKwoVyrFOinuquI8CWInwQ5JidZIei2ZRQw8meVbWGalBQBikaZGf/ 4tCGfrp/fPMEA6+FwhIsunBfm7KDvDFO/fCr3cjOSCpVjmA2GJm9U9yhl3pDTDyq6PKm k6axeYSybKhQeZP2hPp9q5V4fScAzOhl513f/QgVXPVfqjd2Xre56ioIa0Wt9HD1DznO RnTiTJo3y+V7I4nmV1evx4YZyRPaabr4q01R2zySyjK4rpbuEIeunktjibzfpPWz7e6u 3m5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=vpauSbDUiXOwVp8Xv14le33bjVkV/5/lAUr4AGJG7ek=; b=e6G9pBN+SaeFVQc8mndcAXZcI1ni+bXs58Ytl5iaHezpgjWiyXE5l3MRe76yaCNQhw DPBy5F/XviOml8JNJI0yaOwmxkq4BH9KDyorw7n11KaACgumvmzKwmn0+dSSxgMQv8gQ 4NaLTJXtuiw7z3/LTk7+cqS8loEvyhM5Gq0+SRAUx3Rq1ktaNIrqdixUVV3M/9saq+Gp kXKc8eLaHq/qOlkLAAfVck2GaveXJqxHWCYdhKWZttOG1xjGP2rbMCTc3aCKaecClquF bmuJRF8q1ipTciAZVQHsvM1S3UAwD0UA3uDpgtfXlZ9QQuW/5sIa2wO7GprtwdfyRS14 /0WA== X-Gm-Message-State: ACrzQf1bg11MW8DQcoKMwwt/IpYOAfxJQ7I0mk0Jnh6kchipfEM3Sucg IrRd0xQEqJwsE0X8zveaoWnqzTUX8dA= X-Google-Smtp-Source: AMsMyM4Odzv3ColSGdVJkkPv4FHU3+mvxf9c7ADJ8wY+oMV8fxdN0fqoc53N+Dlq23z0l0nmnTcMaQ== X-Received: by 2002:a17:906:4fc3:b0:72e:eab4:d9d7 with SMTP id i3-20020a1709064fc300b0072eeab4d9d7mr23784709ejw.599.1665611055692; Wed, 12 Oct 2022 14:44:15 -0700 (PDT) Received: from [10.0.0.1] (138.sub226.ddfr.nl. [217.27.226.138]) by smtp.gmail.com with ESMTPSA id g9-20020aa7c589000000b00456d2721d93sm11923365edq.64.2022.10.12.14.44.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Oct 2022 14:44:15 -0700 (PDT) Message-ID: <3f91174f-598a-6c19-4b73-f19d710b6bd1@gmail.com> Date: Wed, 12 Oct 2022 23:44:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Content-Language: en-US To: gcc-help From: "J.W. Jagersma" Subject: Ignoring 'target specific option mismatch' on inline Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.2 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Consider the following (incomplete) code: enum simd { mmx = 1, sse = 2 /* , ... */ }; template void simd_func() { if constexpr (flags & simd::mmx) { // MMX code here } else if constexpr (flags & simd::sse) { // SSE code here } // etc ... } The idea is to instantiate function templates with optimized SIMD routines multiple times, then I can compile all my code with -march=i386, and select the best implementation at runtime. However, after already spending a lot of time restructuring my code around this idea, I discover that gcc refuses to compile this without having the corresponding target options enabled: error: inlining failed in call to 'always_inline' '__m64 _mm_unpacklo_pi8(__m64, __m64)': target specific option mismatch That makes no sense to me. I want gcc to emit those SIMD instructions verbatim in my code, regardless of what compiler options the user specified. What then is the point of feature-test macros (__SSE__, etc)? I don't get it. Is there any option or attribute I can use to make gcc ignore these target option mismatches when inlining? Or any other way to make this work?