@@ -400,7 +400,8 @@ static bool tryToFPToSat(Instruction &I, TargetTransformInfo &TTI) {
400
400
// / pessimistic codegen that has to account for setting errno and can enable
401
401
// / vectorization.
402
402
static bool foldSqrt (Instruction &I, TargetTransformInfo &TTI,
403
- TargetLibraryInfo &TLI) {
403
+ TargetLibraryInfo &TLI, AssumptionCache &AC,
404
+ DominatorTree &DT) {
404
405
// Match a call to sqrt mathlib function.
405
406
auto *Call = dyn_cast<CallInst>(&I);
406
407
if (!Call)
@@ -424,7 +425,8 @@ static bool foldSqrt(Instruction &I, TargetTransformInfo &TTI,
424
425
Value *Arg = Call->getArgOperand (0 );
425
426
if (TTI.haveFastSqrt (Ty) &&
426
427
(Call->hasNoNaNs () ||
427
- CannotBeOrderedLessThanZero (Arg, M->getDataLayout (), &TLI))) {
428
+ cannotBeOrderedLessThanZero (Arg, M->getDataLayout (), &TLI, 0 , &AC, &I,
429
+ &DT))) {
428
430
IRBuilder<> Builder (&I);
429
431
IRBuilderBase::FastMathFlagGuard Guard (Builder);
430
432
Builder.setFastMathFlags (Call->getFastMathFlags ());
@@ -918,7 +920,8 @@ static bool foldPatternedLoads(Instruction &I, const DataLayout &DL) {
918
920
// / occur frequently and/or have more than a constant-length pattern match.
919
921
static bool foldUnusualPatterns (Function &F, DominatorTree &DT,
920
922
TargetTransformInfo &TTI,
921
- TargetLibraryInfo &TLI, AliasAnalysis &AA) {
923
+ TargetLibraryInfo &TLI, AliasAnalysis &AA,
924
+ AssumptionCache &AC) {
922
925
bool MadeChange = false ;
923
926
for (BasicBlock &BB : F) {
924
927
// Ignore unreachable basic blocks.
@@ -943,7 +946,7 @@ static bool foldUnusualPatterns(Function &F, DominatorTree &DT,
943
946
// NOTE: This function introduces erasing of the instruction `I`, so it
944
947
// needs to be called at the end of this sequence, otherwise we may make
945
948
// bugs.
946
- MadeChange |= foldSqrt (I, TTI, TLI);
949
+ MadeChange |= foldSqrt (I, TTI, TLI, AC, DT );
947
950
}
948
951
}
949
952
@@ -964,7 +967,7 @@ static bool runImpl(Function &F, AssumptionCache &AC, TargetTransformInfo &TTI,
964
967
const DataLayout &DL = F.getParent ()->getDataLayout ();
965
968
TruncInstCombine TIC (AC, TLI, DL, DT);
966
969
MadeChange |= TIC.run (F);
967
- MadeChange |= foldUnusualPatterns (F, DT, TTI, TLI, AA);
970
+ MadeChange |= foldUnusualPatterns (F, DT, TTI, TLI, AA, AC );
968
971
return MadeChange;
969
972
}
970
973
0 commit comments