0

Not many architectures have skip instructions today. They are (usually) conditional instructions that skip the following instruction. A few architectures having these:

  • PIC14, with its btfss and btfsc instructions
  • Most PDP's from DEC (perhaps most famously the PDP-10)
  • Data General NOVA

I'm writing a superoptimizer (just a hobby, won't be big and professional like GNU superopt) which does code generation so I'm doing some research into compiler terminology and the related concepts.

I'm still trying to work out why the notion of basic block is useful, but also, if skip instructions count as branch instructions for the purposes of determining whether they may be included in basic blocks and extended basic blocks.

On the one hand, they are like a conditional branch with an implicit forward destination, so could be treated the same as a conditional branch instruction. On the other hand, a skip instruction followed by a load is equivalent to a conditional-move instruction. Or a skip-if-negative instruction followed by a subtract-from-zero instruction implements a get-absolute-value instruction, and these are permitted inside of a basic block.

So how do compiler writers and others generally reason about this?

  • When you understand why basic blocks are useful you might have some ideas about how you should treat skip instructions. – user253751 Oct 28 '21 at 11:36
  • @user253751 do you have any leads? – Omar and Lorraine Oct 28 '21 at 12:25
  • In the ARM instruction sets, nearly every instruction supports conditional execution which amounts to a skip pseudo-instruction. Perhaps you can find prior art in that area. Whether you treat each such skips as a basic block depends entirely on your purposes. If you want to construct the control flow graph it's definitely a branch. If you construct a static single assignment form, you will definitely need Phi nodes. But I guess you could safely do some peephole optimization across a skip instruction without treating it as an actual branching point. – amon Oct 29 '21 at 10:22

0 Answers0