[PATCH] D128039: Fix D125335 accidentally change control flow.

Han-Kuan Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 17 08:42:18 PDT 2022


HanKuanChen added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineCopyPropagation.cpp:663
 
-      if (TRI->regsOverlap(RegDef, RegSrc))
-        continue;
-
-      assert(RegDef.isPhysical() && RegSrc.isPhysical() &&
-             "MachineCopyPropagation should be run after register allocation!");
-
-      MCRegister Def = RegDef.asMCReg();
-      MCRegister Src = RegSrc.asMCReg();
-
-      // The two copies cancel out and the source of the first copy
-      // hasn't been overridden, eliminate the second one. e.g.
-      //  %ecx = COPY %eax
-      //  ... nothing clobbered eax.
-      //  %eax = COPY %ecx
-      // =>
-      //  %ecx = COPY %eax
-      //
-      // or
-      //
-      //  %ecx = COPY %eax
-      //  ... nothing clobbered eax.
-      //  %ecx = COPY %eax
-      // =>
-      //  %ecx = COPY %eax
-      if (eraseIfRedundant(MI, Def, Src) || eraseIfRedundant(MI, Src, Def))
-        continue;
+      if (!TRI->regsOverlap(RegDef, RegSrc)) {
+        assert(RegDef.isPhysical() && RegSrc.isPhysical() &&
----------------
adriantong1024 wrote:
> Is this not the same as what is here already ?
No. The line 658 and 736 are included by the same loop (line 655).


================
Comment at: llvm/lib/CodeGen/MachineCopyPropagation.cpp:933
 
-      if (TRI->regsOverlap(DefReg, SrcReg))
-        continue;
-
-      MCRegister Def = DefReg.asMCReg();
-      MCRegister Src = SrcReg.asMCReg();
+      if (!TRI->regsOverlap(DefReg, SrcReg)) {
+        MCRegister Def = DefReg.asMCReg();
----------------
adriantong1024 wrote:
> Same here. Is this not the same as what is here already ?
Same. The line 929 and 949 are included by the same loop (line 926).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128039/new/

https://reviews.llvm.org/D128039



More information about the llvm-commits mailing list