[llvm] [GlobalISel] Fold G_ICMP if possible (PR #86357)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 10:42:52 PDT 2024


================
@@ -7673,12 +7680,16 @@ 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, NewDst0, LHS);
   auto ConditionRHS = MIRBuilder.buildICmp(
       IsAdd ? CmpInst::ICMP_SLT : CmpInst::ICMP_SGT, BoolTy, RHS, Zero);
 
-  MIRBuilder.buildXor(Dst1, ConditionRHS, ResultLowerThanLHS);
+  MIRBuilder.buildXor(NewDst1, ConditionRHS, ResultLowerThanLHS);
+
+  MIRBuilder.buildCopy(Dst0, NewDst0);
+  MIRBuilder.buildCopy(Dst1, NewDst1);
----------------
shiltian wrote:

Yes

https://github.com/llvm/llvm-project/pull/86357


More information about the llvm-commits mailing list