InstructionCombining.cpp inconsistency in whether it modifies the CFG?

InstCombine says in its getAnalysisUsage that it preserves the CFG,
but for the 4th argument in its INITIALIZE_PASS call, it says false,
which I believe corresponds to whether it preserves the CFG. Is this a
mistake, or is there deeper meaning here?

InstructionCombining.cpp:73-82

char InstCombiner::ID = 0;
INITIALIZE_PASS(InstCombiner, "instcombine",
                "Combine redundant instructions", false, false)

void InstCombiner::getAnalysisUsage(AnalysisUsage &AU) const {
  AU.addPreservedID(LCSSAID);
  AU.setPreservesCFG();
}

Hi Michael,

InstCombine says in its getAnalysisUsage that it preserves the CFG,
but for the 4th argument in its INITIALIZE_PASS call, it says false,
which I believe corresponds to whether it preserves the CFG.

that argument should be set to true if the pass only looks at the CFG, i.e.
whatever it computes/does is only a function of the CFG, and doesn't otherwise
depend on what particular instructions make up the function. Suppose an
analysis pass A has this property, and a transform pass P announces (using
setPreservesCFG()) that it does not change the CFG. Then A does not need
to be recomputed after P has run.

So I think it is correct for InstCombine to not set this flag.

Ciao, Duncan.

  Is this a

Ah, I see, thanks for the clarification. I interpreted “Pass only looks at the CFG” as didn’t modify it, only looked at it, but I see now that it can also mean “Pass looks only at the CFG”, as in not the instructions.

Thanks!