@@ -2092,11 +2092,19 @@ Value *LibCallSimplifier::replacePowWithExp(CallInst *Pow, IRBuilderBase &B) {
2092
2092
if (!Ty->isVectorTy () && match (Base, m_SpecificFP (2.0 )) &&
2093
2093
(isa<SIToFPInst>(Expo) || isa<UIToFPInst>(Expo)) &&
2094
2094
hasFloatFn (M, TLI, Ty, LibFunc_ldexp, LibFunc_ldexpf, LibFunc_ldexpl)) {
2095
- if (Value *ExpoI = getIntToFPVal (Expo, B, TLI->getIntSize ()))
2096
- return copyFlags (*Pow,
2097
- emitBinaryFloatFnCall (ConstantFP::get (Ty, 1.0 ), ExpoI,
2098
- TLI, LibFunc_ldexp, LibFunc_ldexpf,
2099
- LibFunc_ldexpl, B, NoAttrs));
2095
+ if (Value *ExpoI = getIntToFPVal (Expo, B, TLI->getIntSize ())) {
2096
+ Constant *One = ConstantFP::get (Ty, 1.0 );
2097
+
2098
+ if (Pow->doesNotAccessMemory ()) {
2099
+ return copyFlags (*Pow, B.CreateIntrinsic (Intrinsic::ldexp,
2100
+ {Ty, ExpoI->getType ()},
2101
+ {One, ExpoI}, Pow, " exp2" ));
2102
+ }
2103
+
2104
+ return copyFlags (*Pow, emitBinaryFloatFnCall (
2105
+ One, ExpoI, TLI, LibFunc_ldexp, LibFunc_ldexpf,
2106
+ LibFunc_ldexpl, B, NoAttrs));
2107
+ }
2100
2108
}
2101
2109
2102
2110
// pow(2.0 ** n, x) -> exp2(n * x)
0 commit comments