diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -2164,8 +2164,8 @@ return nullptr; ExpoF = &ExpoI; - Sqrt = getSqrtCall(Base, Pow->getCalledFunction()->getAttributes(), - Pow->doesNotAccessMemory(), M, B, TLI); + Sqrt = getSqrtCall(Base, AttributeList(), Pow->doesNotAccessMemory(), M, + B, TLI); if (!Sqrt) return nullptr; } diff --git a/llvm/test/Transforms/InstCombine/pow-to-sqrt.ll b/llvm/test/Transforms/InstCombine/pow-to-sqrt.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/pow-to-sqrt.ll @@ -0,0 +1,14 @@ +; RUN: opt < %s -passes=instcombine -S | FileCheck %s +; This is a check to assure the attributes of `pow` do +; not get passed to sqrt. + +define void @pow_to_sqrt(double %x) { +; CHECK-LABEL: @pow_to_sqrt( +; CHECK-NEXT: [[SQRT:%.*]] = call afn double @sqrt(double [[X:%.*]]) +; CHECK-NEXT: ret void +; + %call = call afn double @pow(double %x, double 1.5) + ret void +} + +declare double @pow(double noundef, double noundef)