[InstCombine] Avoid passing pow attributes to sqrt
As described in issue #58475, we could pass the attributes of pow to sqrt and crash. Differential Revision: https://reviews.llvm.org/D137454
This commit is contained in:
committed by
Sanjay Patel
parent
b62c81b836
commit
de36d39e24
@@ -2164,8 +2164,8 @@ Value *LibCallSimplifier::optimizePow(CallInst *Pow, IRBuilderBase &B) {
|
||||
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;
|
||||
}
|
||||
|
||||
14
llvm/test/Transforms/InstCombine/pow-to-sqrt.ll
Normal file
14
llvm/test/Transforms/InstCombine/pow-to-sqrt.ll
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user