llvm / llvm/llvm-project

__builtin_cpu_supports should be converted to a constant based on -march

Open
#180,427 7 comments 0 reactions 0 assignees View on GitHub
clang:frontend
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

__builtin_cpu_supports(“foo”) should be collapsed to a constant if foo is unconditionally enabled by -march, for example __builtin_cpu_supports(“avx2”) should be true with -mavx2.

This will greatly simplify use cases that support both static and runtime dispatch.

Contributor guide

Open the contributing guide

Research direction

Start by locating the implementation of __builtin_cpu_supports and the handling of -march in LLVM. Trace how enabled CPU features are represented and how the builtin is lowered, then identify the relevant compiler tests. Done means the builtin becomes a compile-time constant when the requested feature is unconditionally enabled by -march, while runtime dispatch remains supported otherwise.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.