[llvm] [InstCombine] Copy metadata in select-to-masked.load fold (PR #211965)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 25 17:08:52 PDT 2026
================
@@ -5306,12 +5306,15 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
Value *MaskedLoadPtr;
if (match(TrueVal, m_OneUse(m_MaskedLoad(m_Value(MaskedLoadPtr),
- m_Specific(CondVal), m_Value()))))
- return replaceInstUsesWith(
- SI, Builder.CreateMaskedLoad(
+ m_Specific(CondVal), m_Value())))){
+
+ llvm::IntrinsicInst *OldLoad = cast<IntrinsicInst>(TrueVal);
+ Instruction* In = Builder.CreateMaskedLoad(
TrueVal->getType(), MaskedLoadPtr,
- cast<IntrinsicInst>(TrueVal)->getParamAlign(0).valueOrOne(),
- CondVal, FalseVal));
+ OldLoad->getParamAlign(0).valueOrOne(),
+ CondVal, FalseVal);
+ In->copyMetadata(*OldLoad);
----------------
muhammadshayanasim1-web wrote:
Hi, sorry for the delayed response. In commit ba79687 I drop a list of Metadata defined on values (referenced LangRef and existing mechanisms for dropping metadata). Am I correct in explicitly removing these types, or should I use multiple existing functions (i:e dropUBImplyingAttrsAndMetadata, dropPoisonGeneratingMetadata) to achieve desired functionality. Sorry if this is not the correct way or if I impose burden.
https://github.com/llvm/llvm-project/pull/211965
More information about the llvm-commits
mailing list