llvm / llvm/llvm-project

[SimplifyCFG] Presence of llvm.assume prevents folding identical blocks

Open
#205,097 0 comments 0 reactions 0 assignees View on GitHub
llvm:transforms missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Another case were the mere presence of llvm.assume calls prevents optimization, here the elimination of otherwise identical blocks.

Example: https://godbolt.org/z/1Ez3o8xWa
Note that fn1 is optimized as intended, but in fn2, SimplifyCFG adds the assume that prevents later optimization.

Additional note: codegen would be better if the information would be attached as range to the argument.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the fn1 and fn2 examples from the linked Godbolt case, then read the SimplifyCFG implementation and follow how llvm.assume affects identical-block elimination. Done means the otherwise identical blocks are folded despite the assume calls, with the relevant compiler tests covering the regression.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.