@@ -3455,16 +3455,18 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
34553455 // select a, false, b -> select !a, b, false
34563456 if (match (TrueVal, m_Specific (Zero))) {
34573457 Value *NotCond = Builder.CreateNot (CondVal, " not." + CondVal->getName ());
3458+ Instruction *MDFrom = ProfcheckDisableMetadataFixes ? nullptr : &SI;
34583459 SelectInst *NewSI =
3459- SelectInst::Create (NotCond, FalseVal, Zero, " " , nullptr , &SI );
3460+ SelectInst::Create (NotCond, FalseVal, Zero, " " , nullptr , MDFrom );
34603461 NewSI->swapProfMetadata ();
34613462 return NewSI;
34623463 }
34633464 // select a, b, true -> select !a, true, b
34643465 if (match (FalseVal, m_Specific (One))) {
34653466 Value *NotCond = Builder.CreateNot (CondVal, " not." + CondVal->getName ());
3467+ Instruction *MDFrom = ProfcheckDisableMetadataFixes ? nullptr : &SI;
34663468 SelectInst *NewSI =
3467- SelectInst::Create (NotCond, One, TrueVal, " " , nullptr , &SI );
3469+ SelectInst::Create (NotCond, One, TrueVal, " " , nullptr , MDFrom );
34683470 NewSI->swapProfMetadata ();
34693471 return NewSI;
34703472 }
@@ -3474,8 +3476,9 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
34743476 if (match (&SI, m_LogicalAnd (m_Not (m_Value (A)), m_Not (m_Value (B)))) &&
34753477 (CondVal->hasOneUse () || TrueVal->hasOneUse ()) &&
34763478 !match (A, m_ConstantExpr ()) && !match (B, m_ConstantExpr ())) {
3479+ Instruction *MDFrom = ProfcheckDisableMetadataFixes ? nullptr : &SI;
34773480 SelectInst *NewSI =
3478- cast<SelectInst>(Builder.CreateSelect (A, One, B, " " , &SI ));
3481+ cast<SelectInst>(Builder.CreateSelect (A, One, B, " " , MDFrom ));
34793482 NewSI->swapProfMetadata ();
34803483 return BinaryOperator::CreateNot (NewSI);
34813484 }
@@ -3485,8 +3488,9 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
34853488 if (match (&SI, m_LogicalOr (m_Not (m_Value (A)), m_Not (m_Value (B)))) &&
34863489 (CondVal->hasOneUse () || FalseVal->hasOneUse ()) &&
34873490 !match (A, m_ConstantExpr ()) && !match (B, m_ConstantExpr ())) {
3491+ Instruction *MDFrom = ProfcheckDisableMetadataFixes ? nullptr : &SI;
34883492 SelectInst *NewSI =
3489- cast<SelectInst>(Builder.CreateSelect (A, B, Zero, " " , &SI ));
3493+ cast<SelectInst>(Builder.CreateSelect (A, B, Zero, " " , MDFrom ));
34903494 NewSI->swapProfMetadata ();
34913495 return BinaryOperator::CreateNot (NewSI);
34923496 }
0 commit comments