After long debugging, I found last week the reason this optimization originally broke some hdf5 tests. We now pass the hdf5 test suite with the optimization being actively used.