[llvm] [RISCV] Allow hoisting VXRM writes out of loops speculatively (PR #110044)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 10:47:47 PDT 2024


================
@@ -109,6 +109,35 @@ class VXRMInfo {
     return VXRMInfo::getUnknown();
   }
 
+  // Calculate the VXRMInfo visible to a block assuming this and Other
+  // are both predecessors. To allow speculatively running WriteVXRM
+  // we will ignore Unknowns if one of this and Other have valid
+  // WriteVXRM. Rationale: WriteVXRM causes a pipeline flush in some
+  // uarchs and moving it outside loops is very important for some
+  // workloads.
+  VXRMInfo intersectAnticipated(const VXRMInfo &Other) const {
+    // If the new value isn't valid, ignore it.
+    if (!Other.isValid())
+      return *this;
+
+    // If this value isn't valid, this must be the first predecessor, use it.
+    if (!isValid())
+      return Other;
+
+    // If either is unknown, the result is the other one.
+    if (isUnknown())
+      return Other;
+    else if (Other.isUnknown())
----------------
topperc wrote:

No `else` since the `if` always returns. https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

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


More information about the llvm-commits mailing list