Revert "[AArch64][MacroFusion] Check register overlap in WAW check" (#234172)

This reverts commit 77be0679c76d6763f8d2b348a7555d75891e2c09.

Restricting WAW check back to exact match of same dest, as overlap
should not generally be the default and should not have an existing
user.
diff --git a/llvm/lib/Target/AArch64/AArch64MacroFusion.cpp b/llvm/lib/Target/AArch64/AArch64MacroFusion.cpp
index 276855b..b914945 100644
--- a/llvm/lib/Target/AArch64/AArch64MacroFusion.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MacroFusion.cpp
@@ -150,24 +150,21 @@
   return false;
 }
 
-// True unless the pair provably writes non overlapping physical registers.
-// Pre-RA the dests are still virtual, and post-RA it requires a genuine WAW,
-// that is overlapping dest regs. Overlapping includes sub and super register
-// relations, e.g. W0 and X0, which matches the register unit based dependency
-// model of the scheduling DAG.
+// True unless the pair provably writes different physical registers. Pre-RA
+// the dests are still virtual, and post-RA it requires a genuine WAW (same dest
+// reg).
 static bool mayHaveWAWDependency(const MachineInstr &FirstMI,
-                                 const MachineInstr &SecondMI,
-                                 const TargetRegisterInfo *TRI) {
+                                 const MachineInstr &SecondMI) {
   Register DestFirst = FirstMI.getOperand(0).getReg();
   Register DestSecond = SecondMI.getOperand(0).getReg();
   if (!DestFirst.isPhysical() || !DestSecond.isPhysical())
     return true;
-  return TRI->regsOverlap(DestFirst, DestSecond);
+  return DestFirst == DestSecond;
 }
 
 /// AES crypto encoding or decoding.
-static bool isAESPair(const MachineInstr *FirstMI, const MachineInstr &SecondMI,
-                      const TargetRegisterInfo *TRI) {
+static bool isAESPair(const MachineInstr *FirstMI,
+                      const MachineInstr &SecondMI) {
   // Assume the 1st instr to be a wildcard if it is unspecified.
   unsigned SecondOpcode = SecondMI.getOpcode();
   switch (SecondOpcode) {
@@ -179,7 +176,7 @@
     if (FirstMI->getOpcode() != AArch64::AESErr)
       return false;
     return SecondOpcode == AArch64::AESMCrrTied ||
-           mayHaveWAWDependency(*FirstMI, SecondMI, TRI);
+           mayHaveWAWDependency(*FirstMI, SecondMI);
   // AES decode.
   case AArch64::AESIMCrr:
   case AArch64::AESIMCrrTied:
@@ -188,7 +185,7 @@
     if (FirstMI->getOpcode() != AArch64::AESDrr)
       return false;
     return SecondOpcode == AArch64::AESIMCrrTied ||
-           mayHaveWAWDependency(*FirstMI, SecondMI, TRI);
+           mayHaveWAWDependency(*FirstMI, SecondMI);
   }
 
   return false;
@@ -628,8 +625,7 @@
 
 // FMIN + FMAX.
 static bool isFMinFMaxPair(const MachineInstr *FirstMI,
-                           const MachineInstr &SecondMI,
-                           const TargetRegisterInfo *TRI) {
+                           const MachineInstr &SecondMI) {
   if (!isFMinFMax(SecondMI.getOpcode()))
     return false;
 
@@ -640,7 +636,7 @@
   if (!isFMinFMax(FirstMI->getOpcode()))
     return false;
 
-  return mayHaveWAWDependency(*FirstMI, SecondMI, TRI);
+  return mayHaveWAWDependency(*FirstMI, SecondMI);
 }
 
 /// \brief Check if the instr pair, FirstMI and SecondMI, should be fused
@@ -679,7 +675,7 @@
     ++NumFusedArithmeticCbz;
     return true;
   }
-  if (ST.hasFuseAES() && isAESPair(FirstMI, SecondMI, TRI)) {
+  if (ST.hasFuseAES() && isAESPair(FirstMI, SecondMI)) {
     ++NumFusedAES;
     return true;
   }
@@ -720,7 +716,7 @@
     ++NumFusedAddSub2RegAndConstOne;
     return true;
   }
-  if (ST.hasFuseFMinFMax() && isFMinFMaxPair(FirstMI, SecondMI, TRI)) {
+  if (ST.hasFuseFMinFMax() && isFMinFMaxPair(FirstMI, SecondMI)) {
     ++NumFusedFMinFMax;
     return true;
   }
diff --git a/llvm/test/CodeGen/AArch64/misched-fusion-fmin-fmax-post-ra.mir b/llvm/test/CodeGen/AArch64/misched-fusion-fmin-fmax-post-ra.mir
index 7c82c7c..30ba02e 100644
--- a/llvm/test/CodeGen/AArch64/misched-fusion-fmin-fmax-post-ra.mir
+++ b/llvm/test/CodeGen/AArch64/misched-fusion-fmin-fmax-post-ra.mir
@@ -1030,21 +1030,3 @@
     $q6 = FADDv2f64 $q3, $q4, implicit $fpcr
     $q7 = FMINv2f64 $q5, $q2, implicit $fpcr
 ...
-# A representative pair that writes different but overlapping architectural registers,
-# which share physical register storage and form a WAW dependency.
----
-name: fmax_fmin_h_s_overlap
-tracksRegLiveness: true
-body: |
-  bb.0:
-    liveins: $h0, $h1, $s2, $h3, $h4
-    ; CHECK-LABEL: fmax_fmin_h_s_overlap
-    ; CHECK: SU(0): $h5 = FMAXHrr
-    ; CHECK: Successors:
-    ; FUSE: SU(2): Ord  Latency={{[0-9]+}} Cluster
-    ; NOFUSE-NOT: SU(2): Ord  Latency={{[0-9]+}} Cluster
-    ; CHECK: SU(2): $s5 = FMINSrr
-    $h5 = FMAXHrr $h0, $h1, implicit $fpcr
-    $h6 = FADDHrr $h3, $h4, implicit $fpcr
-    $s5 = FMINSrr $s5, $s2, implicit $fpcr
-...