llvm / llvm/llvm-project

Failure to reach fixpoint in 1st iteration when constant folding libcall

Open
#217,832 2 comments 0 reactions 0 assignees View on GitHub
llvm:instcombine missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://llvm.godbolt.org/z/456M4eq6f

We constant fold the call to `floor`, but it's not trivially dead so it hangs around after being RAUWd. Maybe we should mark the `TargetLibraryInfo::hasOptimizedCodeGen` functions as trivially dead?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the Compiler Explorer example at https://llvm.godbolt.org/z/456M4eq6f and observe why the first constant-folding iteration fails to reach a fixpoint. Read the handling of floor and TargetLibraryInfo::hasOptimizedCodeGen, including how the RAUW'd call is classified for dead-code elimination. Done means the example reaches a fixpoint without hanging and the behavior is covered by an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.