[llvm] [SDAG] Avoid creating redundant stack slots when lowering FSINCOS (PR #108401)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 20 09:45:38 PDT 2024
MacDue wrote:
> I think you can drop all of the chain logic and just use DAG.getEntryNode. FSINCOS is derived from no-memory/errno operations, and thus assumed to not care about the state of errno. You don't need all of this code trying to figure out the suitable chain
I don't think that's safe with the stores. Given this IR (which contains a sincos intrinsic with lowers to FSINCOS):
```llvm
define void @test(float %v, ptr %x, ptr %y) {
call void @foo(ptr %x, ptr %y)
%sret = call { float, float } @llvm.sincos.f32(float %v)
%ret0 = extractvalue { float, float } %sret, 0
%ret1 = extractvalue { float, float } %sret, 1
store float %ret0, ptr %x, align 4
store float %ret1, ptr %y, align 4
ret void
}
declare void @foo(ptr, ptr)
```
The stores for the results of `FSINCOS` take the chain from the call to `@foo` as the input. With the current logic, this lowers correctly (a call to `foo` followed by a call to `sincosf`). If I instead make the input chain `DAG.getEntryNode()` the call to `foo` is lost.
https://github.com/llvm/llvm-project/pull/108401
More information about the llvm-commits
mailing list