[llvm] [InstCombine] Preserve profile branch weights when folding logical booleans (PR #161293)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 29 17:02:41 PDT 2025
================
@@ -1722,16 +1722,19 @@ class IRBuilderBase {
return Insert(BinOp, Name);
}
- Value *CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name = "") {
+ Value *CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name = "",
+ Instruction *MDFrom = nullptr) {
assert(Cond2->getType()->isIntOrIntVectorTy(1));
return CreateSelect(Cond1, Cond2,
- ConstantInt::getNullValue(Cond2->getType()), Name);
+ ConstantInt::getNullValue(Cond2->getType()), Name,
+ MDFrom);
----------------
mtrofin wrote:
I *think* it's OK to copy all MD here - presumably callers that don't want any will drop explicitly? I'll defer to @nikic .
Otherwise we could have a instcombine variant that does this.
Separately: the `ProfcheckDisableMetadataFixes` flag?
https://github.com/llvm/llvm-project/pull/161293
More information about the llvm-commits
mailing list