[PATCH] D140917: [AVR] Optimize away cpi instructions when possible

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 23:35:46 PST 2023


benshi001 added inline comments.


================
Comment at: llvm/lib/Target/AVR/AVRInstrInfo.cpp:290
+  for (MachineInstr &Instr : make_range(AfterCmpInstr, CmpMBB.end())) {
+    switch (Instr.getOpcode()) {
+    case AVR::BRNEk:
----------------
Can it be `if (Instr.getOpcode() == AVR::BRNEk || Instr.getOpcode() == AVR::BREQk)` ? I do not think we need a `switch` which means more than 2 choices.


================
Comment at: llvm/lib/Target/AVR/AVRInstrInfo.cpp:301
+    if (Instr.readsRegister(AVR::SREG, TRI))
+      // This instruction might read the Z flag.
+      return false;
----------------
Is this comment line correct? May it be 
```
// This instruction might read other flags (than Z) which are set by CPI.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140917



More information about the llvm-commits mailing list