Skip to content

Commit 8a677a7

Browse files
committed
AMDGPU: Partially respect nobuiltin in libcall simplifier
There are more contexts where it's not handled correctly but this is the simplest one. https://reviews.llvm.org/D156682
1 parent 2dc1a27 commit 8a677a7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ bool AMDGPULibCalls::sincosUseNative(CallInst *aCI, const FuncInfo &FInfo) {
500500
bool AMDGPULibCalls::useNative(CallInst *aCI) {
501501
CI = aCI;
502502
Function *Callee = aCI->getCalledFunction();
503-
if (!Callee)
503+
if (!Callee || aCI->isNoBuiltin())
504504
return false;
505505

506506
FuncInfo FInfo;
@@ -593,7 +593,7 @@ bool AMDGPULibCalls::fold(CallInst *CI, AliasAnalysis *AA) {
593593
this->CI = CI;
594594
Function *Callee = CI->getCalledFunction();
595595
// Ignore indirect calls.
596-
if (!Callee)
596+
if (!Callee || CI->isNoBuiltin())
597597
return false;
598598

599599
IRBuilder<> B(CI);

llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,18 @@ entry:
630630
ret void
631631
}
632632

633+
; GCN-LABEL: {{^}}define amdgpu_kernel void @test_use_native_powr_nobuiltin
634+
; GCN: %call = tail call fast float @_Z4powrff(float %tmp, float %tmp1)
635+
define amdgpu_kernel void @test_use_native_powr_nobuiltin(ptr addrspace(1) nocapture %a) {
636+
entry:
637+
%tmp = load float, ptr addrspace(1) %a, align 4
638+
%arrayidx1 = getelementptr inbounds float, ptr addrspace(1) %a, i64 1
639+
%tmp1 = load float, ptr addrspace(1) %arrayidx1, align 4
640+
%call = call fast float @_Z4powrff(float %tmp, float %tmp1) nobuiltin
641+
store float %call, ptr addrspace(1) %a, align 4
642+
ret void
643+
}
644+
633645
; GCN-LABEL: {{^}}define amdgpu_kernel void @test_use_native_sqrt
634646
; GCN-NATIVE: call fast float @_Z11native_sqrtf(float %tmp)
635647
define amdgpu_kernel void @test_use_native_sqrt(ptr addrspace(1) nocapture %a) {

0 commit comments

Comments
 (0)