[llvm] LAA: improve code in a couple of routines (NFC) (PR #108092)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 28 03:38:32 PST 2024


================
@@ -1976,13 +1976,12 @@ MemoryDepChecker::getDependenceDistanceStrideAndSize(
                     << " Sink induction step: " << StrideBPtrInt << "\n");
   // At least Src or Sink are loop invariant and the other is strided or
   // invariant. We can generate a runtime check to disambiguate the accesses.
-  if (StrideAPtrInt == 0 || StrideBPtrInt == 0)
+  if (!StrideAPtrInt || !StrideBPtrInt)
     return MemoryDepChecker::Dependence::Unknown;
 
   // Both Src and Sink have a constant stride, check if they are in the same
   // direction.
-  if ((StrideAPtrInt > 0 && StrideBPtrInt < 0) ||
-      (StrideAPtrInt < 0 && StrideBPtrInt > 0)) {
+  if (StrideAPtrInt > 0 != StrideBPtrInt > 0) {
----------------
david-arm wrote:

nit: Is it worth adding brackets around each check, i.e. `(StrideAPtrInt > 0) != (StrideBPtrInt > 0)`. Perhaps it's personal preference, but that reads a bit better.

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


More information about the llvm-commits mailing list