An all-optical XOR gate at 40 Gbit/s is demonstrated using ultrafast nonlinear interferometers (UNI) incorporating semiconductor optical amplifiers (SOAs), where no additional probe beam is required. The only inputs launched into the setup are the data A and B. The XOR logic of the data A and B is the sum of two components ĀB and AB̄, each of which is obtained from the output of UNI via cross-phase modulation in SOAs. The SOA switching pulse energy is lower than 33 fJ.