Target DAG-combine vs. Target custom lowering


I am new to LLVM. I read the the Codegen documentation, and browsed thru the code of some of the backends. One thing i didn’t understand was when should a transformation happen in the TargetLowering::PerformDAGCombine and not in the custom lowering phase.

Thanks, Servius

Lowering is really "legalization", so rewriting some construct in a form that is legal on your target. This only happens once. Combining is mostly an optimization, and it happens several times, including before and after legalization.