[PATCH] D59355: [RISCV] Optimize emission of SELECT sequences

Roger Ferrer Ibanez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 23:46:46 PDT 2019


rogfer01 added a comment.

Thanks @luismarques

Looks good to me, just a minor suggestion above.



================
Comment at: lib/Target/RISCV/RISCVISelLowering.cpp:839
+
+  do {
+    SequenceMBBI = skipDebugInstructionsForward(SequenceMBBI, BB->end());
----------------
The [[ https://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop | coding standards]] suggests not to evaluate `->end()` at each iteration. Given that `SequenceMBBI` is dead after this loop, perhaps you can rewrite the loop like this (warning, untested code might not compile nor work!)

```lang=cpp
for (auto E = BB->end(), SequenceMBBI = skipDebugInstructionsForward(
                             MachineOperand::iterator(MI), E);
     SequenceMBBI != E;
     SequenceMBBI = skipDebugInstructionsForward(std::next(SequenceMBBI), E)) {
   ...
}
```

That would imply removing the final `++SequenceMBBI`, too.

Alternative to calling `skipDebugInstructionForward`, you might just evaluate `SequenceMBBI->isDebugInstr()` inside of the loop and just `continue` which would simplify the `for` even further.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59355





More information about the llvm-commits mailing list