IRFs from the ABCD state space representation

Matlab’s state space uses
y_t=\tilde Cx_t+\tilde D\varepsilon_t
, but Dynare’s ABCD form reports
y_t=Cx_{t-1}+D\varepsilon_t.
With
x_t=Ax_{t-1}+B\varepsilon_t
you get
y_t=(\tilde CA) x_{t-1}+(\tilde CB+\tilde D)\varepsilon_t. Comparing coefficients, you should get
\tilde C=CA^{-1}
\tilde D=D-\tilde C B
However, that requires A to be invertible, which it is often not.