[llvm] [GlobalISel] Fold G_ICMP if possible (PR #86357)
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 26 06:17:26 PDT 2024
================
@@ -7638,7 +7644,7 @@ LegalizerHelper::lowerSADDO_SSUBO(MachineInstr &MI) {
// (LHS) if and only if the other operand (RHS) is (non-zero) positive,
// otherwise there will be overflow.
auto ResultLowerThanLHS =
- MIRBuilder.buildICmp(CmpInst::ICMP_SLT, BoolTy, Dst0, LHS);
+ MIRBuilder.buildICmp(CmpInst::ICMP_SLT, BoolTy, Tmp, LHS);
----------------
aemerson wrote:
@shiltian What if we assert in `buildInstr()` that `DstOp` vregs are undefined? That will then force clients to `eraseFromParent()` *before* calling it.
The other idea of having `buildInstr()` erase the MI itself forces each vreg build to call `MRI.getVRegDef()` even if it's never needed, and it's probably unintuitive from an API perspective.
https://github.com/llvm/llvm-project/pull/86357
More information about the llvm-commits
mailing list