@@ -831,17 +831,22 @@ void llvm::computeKnownBitsFromContext(const Value *V, KnownBits &Known,
831831 " Got assumption for the wrong function!" );
832832
833833 if (Elem.Index != AssumptionCache::ExprResultIdx) {
834- if (!V->getType ()->isPointerTy ())
835- continue ;
836- if (RetainedKnowledge RK = getKnowledgeFromBundle (
837- *I, I->bundle_op_info_begin ()[Elem.Index ])) {
834+ if (V->getType ()->isPointerTy ()) {
835+ if (RetainedKnowledge RK = getKnowledgeFromBundle (
836+ *I, I->bundle_op_info_begin ()[Elem.Index ])) {
838837 // Allow AllowEphemerals in isValidAssumeForContext, as the CxtI might
839838 // be the producer of the pointer in the bundle. At the moment, align
840839 // assumptions aren't optimized away.
841- if (RK.WasOn == V && RK.AttrKind == Attribute::Alignment &&
842- isPowerOf2_64 (RK.ArgValue ) &&
843- isValidAssumeForContext (I, Q.CxtI , Q.DT , /* AllowEphemerals*/ true ))
844- Known.Zero .setLowBits (Log2_64 (RK.ArgValue ));
840+ if (RK.WasOn == V && RK.AttrKind == Attribute::Alignment &&
841+ isPowerOf2_64 (RK.ArgValue ) &&
842+ isValidAssumeForContext (I, Q.CxtI , Q.DT , /* AllowEphemerals*/ true ))
843+ Known.Zero .setLowBits (Log2_64 (RK.ArgValue ));
844+ }
845+ } else if (V->getType ()->isIntOrIntVectorTy ()) {
846+ if (std::optional<ConstantRange> Range =
847+ getRangeFromBundle (*I, I->bundle_op_info_begin ()[Elem.Index ]))
848+ if (isValidAssumeForContext (I, Q.CxtI , Q.DT ))
849+ Known = Known.unionWith (Range->toKnownBits ());
845850 }
846851 continue ;
847852 }
0 commit comments