[PATCH] D119654: [SDAG] enable binop identity constant folds for add/sub

LuoYuanke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 16 23:41:24 PST 2022


LuoYuanke added inline comments.


================
Comment at: llvm/test/CodeGen/X86/avx512vnni-intrinsics-upgrade.ll:66
+; X86-NEXT:    vpaddd %zmm0, %zmm3, %zmm3 {%k1} # encoding: [0x62,0xf1,0x65,0x49,0xfe,0xd8]
+; X86-NEXT:    vmovdqa64 %zmm3, %zmm0 # encoding: [0x62,0xf1,0xfd,0x48,0x6f,0xc3]
 ; X86-NEXT:    retl # encoding: [0xc3]
----------------
This can be improved in RA by evict the previous assigned physical register (zmm0) with below patch, but there is some risk on performance regression, because we change the general RA evicting rule. If anyone concern about this additional vmovdqa64, I can separate sub from add in the patch and we may submit sub    patch first.

```
diff --git a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
index 718e12e5d602..863394fffeb6 100644
--- a/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
+++ b/llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp
@@ -168,6 +168,7 @@ bool DefaultEvictionAdvisor::canEvictHintInterference(
     const SmallVirtRegSet &FixedRegisters) const {
   EvictionCost MaxCost;
   MaxCost.setBrokenHints(1);
+  MaxCost.MaxWeight = VirtReg.weight();
   return canEvictInterferenceBasedOnCost(VirtReg, PhysReg, true, MaxCost,
                                          FixedRegisters);
 }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119654



More information about the llvm-commits mailing list