Hmm looks like the compiler may be trying to be clever here. Not sure what you can do about it but some thoughts:
Maybe mess with the equals threshold. It is ineteresting that nothing from that setting made its way into the hlsl but maybe that only happens with default settings?
Also you could try hooking up your two textures as A and B inputs in a custom node, and have just the IF statement in the custom node rather than having to move everything over. It should be the same thing either way I believe (except the instructions won’t appear within the custom expression).