File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
llvm/lib/CodeGen/SelectionDAG Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -4499,6 +4499,17 @@ static const MDNode *getRangeMetadata(const Instruction &I) {
44994499 // transforms that are known not to be poison-safe, such as folding logical
45004500 // and/or to bitwise and/or. For now, only transfer !range if !noundef is
45014501 // also present.
4502+ if (const auto *CB = dyn_cast<CallBase>(&I))
4503+ if (CB->hasRetAttr (Attribute::NoUndef))
4504+ if (std::optional<ConstantRange> CR = CB->getRange ()) {
4505+ Metadata *Range[] = {ConstantAsMetadata::get (ConstantInt::get (
4506+ I.getContext (), CR->getLower ())),
4507+ ConstantAsMetadata::get (ConstantInt::get (
4508+ I.getContext (), CR->getUpper ()))};
4509+
4510+ return MDNode::get (I.getContext (), Range);
4511+ }
4512+
45024513 if (!I.hasMetadata (LLVMContext::MD_noundef))
45034514 return nullptr ;
45044515 return I.getMetadata (LLVMContext::MD_range);
You can’t perform that action at this time.
0 commit comments