[llvm] [VectorCombine] Pass flags during IR creation (PR #193271)
Jack Huang via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 06:25:12 PDT 2026
================
@@ -156,6 +156,12 @@ class VectorCombine {
bool shrinkType(Instruction &I);
bool shrinkLoadForShuffles(Instruction &I);
bool shrinkPhiOfShuffles(Instruction &I);
+ Value *createBinaryOp(Instruction::BinaryOps Opcode, Value *Op0, Value *Op1,
+ BinaryOperator *OldI);
+ Value *createUnaryOp(Instruction::UnaryOps Opcode, Value *Operand,
+ UnaryOperator *OldI);
+ Value *createCmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS,
+ CmpInst *OldI);
----------------
jackhong12 wrote:
I'm not aware of similar patterns elsewhere in the codebase.
In most cases, we construct the instruction first and then propagate the relevant flags afterward. However, in this case we rely on `InstSimplifyFolder`, which may eliminate the instruction during creation. As a result, there isn’t always a stable point after construction where we can safely copy flags, so they need to be passed at creation time.
Additionally, different instructions use different sets of flags, and the requirements are not uniform. This makes it difficult to design generic helper functions.
https://github.com/llvm/llvm-project/pull/193271
More information about the llvm-commits
mailing list