[compiler-rt] [llvm] [CallPromotionUtils]Implement conditional indirect call promotion with vtable-based comparison (PR #81378)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue May 14 17:41:28 PDT 2024
================
@@ -185,12 +187,30 @@ static void createRetBitCast(CallBase &CB, Type *RetTy, CastInst **RetBitCast) {
U->replaceUsesOfWith(&CB, Cast);
}
+// Returns the or result of all icmp instructions.
+static Value *getOrs(const SmallVector<Value *, 2> &ICmps,
+ IRBuilder<> &Builder) {
+ assert(!ICmps.empty() && "Must have at least one icmp instructions");
+ if (ICmps.size() == 1)
+ return ICmps[0];
+
+ SmallVector<Value *, 2> OrResults;
+ int i = 0, NumICmp = ICmps.size();
+ for (i = 0; i + 1 < NumICmp; i += 2)
+ OrResults.push_back(Builder.CreateOr(ICmps[i], ICmps[i + 1], "icmp-or"));
+
+ if (i < NumICmp)
+ OrResults.push_back(ICmps[i]);
+
+ return getOrs(OrResults, Builder);
----------------
nikic wrote:
Is emitting a tree reduction at this point important? If not, you can just use `Builder.CreateOr(ICmps)`.
https://github.com/llvm/llvm-project/pull/81378
More information about the llvm-commits
mailing list