So, it can be of the form if (StartDate < EndDate)
No, it can't. Your compiler needs to generate a call to the DateTime.op_LessThan()
method. The trouble with generating calls to methods is that you cannot know with 100% certainty that the method will not have an observable side-effect. DateTime.op_LessThan does not but that's not something your compiler can find out by itself. You would have to hard-code that rule in your compiler.
The jitter can however, it does know what the code for that method looks like. And it is very small, it will inline the method to a single CPU instruction. Which executes in less than one CPU cycle on average. The branch prediction logic built into the processor ensures that the branch isn't likely to stall the pipeline.
Pretty hard to make the optimizer in your compiler pay off. It can only eliminate common sub-expressions for very simple code without side-effects, but such code already runs very fast. The C# compiler is a good model to follow, it doesn't optimize and leaves the job up the jitter. Optimizations performed by the jitter are described in this answer. And yes, common sub-expression elimination is one such optimization it knows how to perform.
Whether or not it applies the optimization is however unpredictable, it depends on what other code it needs to generate in the method. I haven't checked this specific case, I rather doubt it will due to the branching. There more of it than meets the eye if you also want to provide short-circuit evaluation for the && and || operators. The only way you can find out is looking at the actual generated machine code. Pick the jitter you want to verify with the Platform target setting. Build the Release configuration of your test code. And Tools + Options, Debugging, General, untick the "Suppress JIT optimization" option. And look at the machine code with a breakpoint and Debug + Windows + Disassembly. Watch out for fake test code, it often runs unrealistically fast if the jitter can optimize too much. And watch out for burning way too much time on this :)