llvm / llvm/llvm-project

[GlobalISel] Support for optimized pow is missing

Open
#179,617 5 comments 0 reactions 0 assignees View on GitHub
llvm:globalisel missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

**Godbolt** - https://godbolt.org/z/ez6nnoWcd
**Testcase**
```
define float @pow(float %x) nounwind {
%r = call nsz ninf afn float @llvm.pow.f32(float %x, float 2.5e-01)
ret float %r
}
```
**SDAG**
```
pow: # @pow
sqrtss %xmm0, %xmm0
sqrtss %xmm0, %xmm0
retq
```
Currently **GISEL** only have support for basic **libcall mapping**. Above case it is crashing due to missing legalizer support in **GISEL**.

Contributor guide

Open the contributing guide

Research direction

Start with the GlobalISel legalizer handling for llvm.pow.f32 and compare it with the SDAG result shown in the issue. Use the linked Godbolt testcase to reproduce the crash, then add coverage for the x^0.25 case and verify that GlobalISel lowers it successfully with equivalent behavior.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.