As noted in PR18355, this patch makes it clear that all cases with undef operands have been handled before further constant folding is attempted.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/IR/ConstantFold.cpp | ||
---|---|---|
1001–1003 ↗ | (On Diff #51133) | I don't like this because it will silently accept newly added binary operators. |
Updated so that we assert on unhandled binary instructions with undef operands.
At present we don't handle float binary instructions so I've split these off with a TODO comment instead of asserting - this patch is about clarity not adding the extra handling support.
lib/IR/ConstantFold.cpp | ||
---|---|---|
1008–1011 ↗ | (On Diff #51156) | ConstantFoldBinaryInstruction should only be called with a binary op, I'd move this assert to the start of the function. |
Moved isBinaryOp assert to start of function - with that done we can remove the 'default' option for undef handling and just assert afterward that neither operand is undef, this will pick up any current/future binary instructions that we don't handle undefs for.
lib/IR/ConstantFold.cpp | ||
---|---|---|
923 ↗ | (On Diff #51205) | Can we make this switch (static_cast<BinaryOps>(Opcode)). This would make the switch fully-covered. |
Converted the switch statement to cast to Instruction::BinaryOps - requires that BinaryOpsEnd is added as a case option.
LGTM with nits.
lib/IR/ConstantFold.cpp | ||
---|---|---|
1010–1011 ↗ | (On Diff #51227) | I'd make this llvm_unreachable. |