correctly compute sw_trace_nd and remove if test in sw_trace to gain a
little bit of performance