llvm / llvm/llvm-project

[InstCombine] Fold `!umul_overflow(x, K) && (x * K <u C)` to `x <u ceil(C / K)`

Open
#222,691 0 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

## Description

InstCombine appears to miss the following simplification for unsigned multiplication with overflow:

```text
!umul_overflow(x, K) && (x * K
x x x
x

Contributor guide

Open the contributing guide

Research direction

The issue points to InstCombine and the llvm.umul.with.overflow intrinsic; start by locating existing InstCombine handling for this intrinsic and reproduce the reduced i32 example. Verify the transformation against the supplied Alive2 proof and confirm that the Linux-kernel pattern reduces to x < 14 without changing semantics.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.