Differentiation under the integral if and only if we have an $L^1$ dominator 
Let $f(x)\in L^2(\mathbb{R})$ and define
$$g(t) = \int_\mathbb{R} f^2(x)\exp(-tx^2)dx$$
for $t\geq0$. We want to show that $g(t)$ is continuously differentiable if and only if $xf(x)\in L^2(\mathbb{R})$.

If we have that $xf(x)\in L^2(\mathbb{R})$ then we can use the standard Lebesgue Dominated Convergence technique to show that $g(t)$ is differentiable, and that its derivative is continuous. I'm having trouble, however, showing that $g'(t)$ continuous means that  $xf(x)\in L^2(\mathbb{R})$.
My attempt: It seems intuitive to me that if $g(t)$ is continuously differentiable, it's derivative must be defined by what we'd expect:
$$g'(t) = \int_\mathbb{R} -x^2f^2(x)\exp(-tx^2)dx,$$
but I don't know how I would go about proving this. If we have this fact, then $g'(0)<\infty\Rightarrow xf(x)\in L^2(\mathbb{R})$ and we're done.
Any thoughts?
 A: The "only if" part only holds for real-valued $f$.
For any $f \in L^2(\mathbb{R})$, be it real- or complex-valued, we have the continuous differentiability of
$$g(t) = \int_\mathbb{R} f(x)^2 \exp (-tx^2)\,dx$$
and the formula
$$g'(t) = \int_\mathbb{R} \left(-x^2\right)f(x)^2\exp (-tx^2)\,dx$$
on $(0,+\infty)$ by the dominated convergence theorem, since
$$x \mapsto x^2 \exp(-tx^2)$$
is uniformly bounded for $t \geqslant t_0 > 0$.
Now, if $\lim\limits_{t\to 0} g'(t)$ exists in $\mathbb{R}$, then $g$ is differentiable in $0$ and $g'(0) = \lim\limits_{t\to 0} g'(t)$. Then $g$ is continuously differentiable on $[0,+\infty)$. Conversely, if $g$ is continuously differentiable on $[0,+\infty)$, then $\lim\limits_{t\to 0} g'(t)$ exists and equals $g'(0)$.
Now, if $f$ is real-valued, then the integrand of $g'(t)$ is non-positive, and
$$\lim_{t\to 0} g'(t) = \lim_{t\to 0} \int_\mathbb{R} \left(-x^2\right) f(x)^2\exp(-tx^2)\,dx = -\int_\mathbb{R} x^2 f(x)^2\,dx \in [-\infty,0]$$
by the monotone convergence theorem. The limit is finite if and only if $xf(x) \in L^2(\mathbb{R})$.
If $f$ is complex-valued, then the limit may exist even if $xf(x) \notin L^2(\mathbb{R})$.
Consider
$$f(x) = \begin{cases} 0 &, x < 1\\ \frac{1}{x\sqrt{2k-1}} &, 2k-1 \leqslant x < 2k \\ \frac{i}{x\sqrt{2k}} &, 2k \leqslant x < 2k+1,\end{cases}$$
where $k$ runs through the positive integers.
Then $xf(x) \notin L^2(\mathbb{R})$ since the harmonic series diverges, yet $\lim\limits_{t\to 0} g'(t)$ exists (and equals $-\log 2$), since $x^2f(x)^2$ corresponds to the alternating harmonic series. (There's a little work to do to show that the limit indeed exists and equals the improper Riemann integral of $x^2f(x)^2$.)
