Question on Instruction Combining


In InstructionCombining.cpp, under AddReachableCodeToWorklist, DCE and ConstFold are performed but MadeIRChange is not set to true (lines 2912 and 2924). Is there some underlying assumption that supports this?

Intuitively not setting MadeIRChanges to true at these points could allow Instruction Combining to exit early while there is still work to do.

Thank you,

At first blush, DCE can reduce the number of uses which might encourage InstCombine to further canonicalize which would indicate that we should set the flag. However, that would only matter if the users of the instruction made it to the worklist in the first place which doesn’t appear to be a guarantee.

Do you have any code which is not fully canonicalized by InstCombine?