@@ -432,6 +432,8 @@ namespace {
432
432
BasicBlock *BB);
433
433
bool solveBlockValueOverflowIntrinsic (
434
434
ValueLatticeElement &BBLV, WithOverflowInst *WO, BasicBlock *BB);
435
+ bool solveBlockValueIntrinsic (ValueLatticeElement &BBLV, IntrinsicInst *II,
436
+ BasicBlock *BB);
435
437
void intersectAssumeOrGuardBlockValueConstantRange (Value *Val,
436
438
ValueLatticeElement &BBLV,
437
439
Instruction *BBI);
@@ -649,6 +651,9 @@ bool LazyValueInfoImpl::solveBlockValueImpl(ValueLatticeElement &Res,
649
651
if (auto *WO = dyn_cast<WithOverflowInst>(EVI->getAggregateOperand ()))
650
652
if (EVI->getNumIndices () == 1 && *EVI->idx_begin () == 0 )
651
653
return solveBlockValueOverflowIntrinsic (Res, WO, BB);
654
+
655
+ if (auto *II = dyn_cast<IntrinsicInst>(BBI))
656
+ return solveBlockValueIntrinsic (Res, II, BB);
652
657
}
653
658
654
659
LLVM_DEBUG (dbgs () << " compute BB '" << BB->getName ()
@@ -1112,6 +1117,37 @@ bool LazyValueInfoImpl::solveBlockValueOverflowIntrinsic(
1112
1117
});
1113
1118
}
1114
1119
1120
+ bool LazyValueInfoImpl::solveBlockValueIntrinsic (
1121
+ ValueLatticeElement &BBLV, IntrinsicInst *II, BasicBlock *BB) {
1122
+ switch (II->getIntrinsicID ()) {
1123
+ case Intrinsic::uadd_sat:
1124
+ return solveBlockValueBinaryOpImpl (BBLV, II, BB,
1125
+ [](const ConstantRange &CR1, const ConstantRange &CR2) {
1126
+ return CR1.uadd_sat (CR2);
1127
+ });
1128
+ case Intrinsic::usub_sat:
1129
+ return solveBlockValueBinaryOpImpl (BBLV, II, BB,
1130
+ [](const ConstantRange &CR1, const ConstantRange &CR2) {
1131
+ return CR1.usub_sat (CR2);
1132
+ });
1133
+ case Intrinsic::sadd_sat:
1134
+ return solveBlockValueBinaryOpImpl (BBLV, II, BB,
1135
+ [](const ConstantRange &CR1, const ConstantRange &CR2) {
1136
+ return CR1.sadd_sat (CR2);
1137
+ });
1138
+ case Intrinsic::ssub_sat:
1139
+ return solveBlockValueBinaryOpImpl (BBLV, II, BB,
1140
+ [](const ConstantRange &CR1, const ConstantRange &CR2) {
1141
+ return CR1.ssub_sat (CR2);
1142
+ });
1143
+ default :
1144
+ LLVM_DEBUG (dbgs () << " compute BB '" << BB->getName ()
1145
+ << " ' - overdefined (unknown intrinsic).\n " );
1146
+ BBLV = ValueLatticeElement::getOverdefined ();
1147
+ return true ;
1148
+ }
1149
+ }
1150
+
1115
1151
static ValueLatticeElement getValueFromICmpCondition (Value *Val, ICmpInst *ICI,
1116
1152
bool isTrueDest) {
1117
1153
Value *LHS = ICI->getOperand (0 );
0 commit comments