[llvm] [VectorCombine] Pass flags during IR creation (PR #193271)
Jack Huang via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 10 23:12:57 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:
There is a function called CreateBinOp in IRBuilder. I think we can extend its interface to include additional flags, with default values set to false, for example:
```diff
Value *CreateBinOp(Instruction::BinaryOps Opc,
Value *LHS,
Value *RHS,
const Twine &Name = "",
- MDNode *FPMathTag = nullptr) {
+ MDNode *FPMathTag = nullptr,
+ bool HasNUW = false,
+ bool HasNSW = false,
+ bool IsExact = false,
+ bool IsDisjoint = false) {
- return CreateBinOpFMF(Opc, LHS, RHS, {}, Name, FPMathTag);
+ return CreateBinOpFMF(Opc, LHS, RHS, {}, Name, FPMathTag,
+ HasNUW, HasNSW, IsExact, IsDisjoint);
}
```
This change would be backward compatible, as all new parameters have default values, so existing code would continue to work unchanged. The main effort would be to propagate these flags and implement the corresponding handling.
Please let me know if you have any suggestions or concerns.😊
https://github.com/llvm/llvm-project/pull/193271
More information about the llvm-commits
mailing list