Here is a probably-related program with a series of ternary conditionals that also mis-compiles with "Maximize Speed", but without any common sub-expressions:
#include <stdio.h>
#include <math.h>
int main(int argc, char **argv)
{
int i;
float x, y;
scanf("%d,%f6.3", &i, &x);
y = (i < 3) ? nan("low") :
(i > 7) ? nan("high") :
(x == 0.0) ? 0.0 :
(float)i / x;
}
Again, this program compiles correctly with optimizations = "None", but there is something weird about the output; the common jump target of the selection expression, after each selectee stores its result in [ebp - 18], is:
fld qword ptr [ebp-18]
fstp qword ptr [ebp-18]
fld qword ptr [ebp-18]
fstp qword ptr [ebp-18]
fld qword ptr [ebp-18]
fstp qword ptr [y]
A lot of action for very little result :-)