[PATCH] D130188: [DependenceAnalysis][PR56275] Normalize dependence analysis results to be non-negative when required

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 22 12:27:00 PDT 2022


Meinersbur added inline comments.


================
Comment at: llvm/lib/Analysis/DependenceAnalysis.cpp:4157-4159
+    if (Result.getDirection(Level) == Dependence::DVEntry::LT ||
+        Result.getDirection(Level) == Dependence::DVEntry::LE)
+      return false;
----------------
The code falls into the final `return false` anyway, i.e. this condition is redundant.

You could also use a `switch` statement.


================
Comment at: llvm/lib/Analysis/DependenceAnalysis.cpp:4179
+    Direction =
+        (Direction & 0x04) >> 2 | (Direction & 0x01) << 2 | (Direction & 0x02);
+    Result.DV[Level - 1].Direction =
----------------
Can we avoid bit-operations with magic constants? 0x01 is `LT`, 0x02 is `EQ`, 0x04 is `GT`. 0x07 is `ALL`.


================
Comment at: llvm/lib/Analysis/DependenceAnalysis.cpp:4181
+    Result.DV[Level - 1].Direction =
+        (Result.DV[Level - 1].Direction & 0xF8) | Direction;
+    // Reverse the dependence distance as well.
----------------
`.Direction` is a bitfield. The compiler already does the masking for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130188



More information about the llvm-commits mailing list