@@ -289,21 +289,52 @@ bool llvm::isKnownNonNegative(const Value *V, const SimplifyQuery &SQ,
289
289
return computeKnownBits (V, Depth, SQ).isNonNegative ();
290
290
}
291
291
292
- bool llvm::isKnownPositive (const Value *V, const SimplifyQuery &SQ,
293
- unsigned Depth) {
292
+ static bool isKnownPositive (const Value *V, const APInt &DemandedElts,
293
+ KnownBits &Known, const SimplifyQuery &SQ,
294
+ unsigned Depth) {
294
295
if (auto *CI = dyn_cast<ConstantInt>(V))
295
296
return CI->getValue ().isStrictlyPositive ();
296
297
297
298
// If `isKnownNonNegative` ever becomes more sophisticated, make sure to keep
298
299
// this updated.
299
- KnownBits Known = computeKnownBits (V, Depth, SQ);
300
+ Known = computeKnownBits (V, DemandedElts , Depth, SQ);
300
301
return Known.isNonNegative () &&
301
- (Known.isNonZero () || ::isKnownNonZero (V, Depth, SQ));
302
+ (Known.isNonZero () || ::isKnownNonZero (V, DemandedElts, Depth, SQ));
303
+ }
304
+
305
+ bool llvm::isKnownPositive (const Value *V, const APInt &DemandedElts,
306
+ const SimplifyQuery &SQ, unsigned Depth) {
307
+ KnownBits Known (getBitWidth (V->getType (), SQ.DL ));
308
+ return ::isKnownPositive (V, DemandedElts, Known, SQ, Depth);
309
+ }
310
+
311
+ bool llvm::isKnownPositive (const Value *V, const SimplifyQuery &SQ,
312
+ unsigned Depth) {
313
+ auto *FVTy = dyn_cast<FixedVectorType>(V->getType ());
314
+ APInt DemandedElts =
315
+ FVTy ? APInt::getAllOnes (FVTy->getNumElements ()) : APInt (1 , 1 );
316
+ return isKnownPositive (V, DemandedElts, SQ, Depth);
317
+ }
318
+
319
+ static bool isKnownNegative (const Value *V, const APInt &DemandedElts,
320
+ KnownBits &Known, const SimplifyQuery &SQ,
321
+ unsigned Depth) {
322
+ Known = computeKnownBits (V, DemandedElts, Depth, SQ);
323
+ return Known.isNegative ();
324
+ }
325
+
326
+ bool llvm::isKnownNegative (const Value *V, const APInt &DemandedElts,
327
+ const SimplifyQuery &SQ, unsigned Depth) {
328
+ KnownBits Known (getBitWidth (V->getType (), SQ.DL ));
329
+ return ::isKnownNegative (V, DemandedElts, Known, SQ, Depth);
302
330
}
303
331
304
332
bool llvm::isKnownNegative (const Value *V, const SimplifyQuery &SQ,
305
333
unsigned Depth) {
306
- return computeKnownBits (V, Depth, SQ).isNegative ();
334
+ auto *FVTy = dyn_cast<FixedVectorType>(V->getType ());
335
+ APInt DemandedElts =
336
+ FVTy ? APInt::getAllOnes (FVTy->getNumElements ()) : APInt (1 , 1 );
337
+ return isKnownNegative (V, DemandedElts, SQ, Depth);
307
338
}
308
339
309
340
static bool isKnownNonEqual (const Value *V1, const Value *V2, unsigned Depth,
0 commit comments