     CV_DbgAssert( depth <= CV_32F );
     CV_DbgAssert( op >= 0 && op < 3 );
 
-    if (depth == CV_32F || depth == CV_32S)
-    {
-        funcs32[op](src1, src2, dst, mask, stream);
-    }
-    else if (depth == CV_16S || depth == CV_16U)
-    {
-        funcs16[op](src1, src2, dst, mask, stream);
+    if (mask.empty())
+    {
+        const int bcols = (int) (src1.cols * src1.elemSize());
+
+        if ((bcols & 3) == 0)
+        {
+            const int vcols = bcols >> 2;
+
+            GpuMat vsrc1(src1.rows, vcols, CV_32SC1, src1.data, src1.step);
+            GpuMat vsrc2(src1.rows, vcols, CV_32SC1, src2.data, src2.step);
+            GpuMat vdst(src1.rows, vcols, CV_32SC1, dst.data, dst.step);
+
+            funcs32[op](vsrc1, vsrc2, vdst, GpuMat(), stream);
+        }
+        else if ((bcols & 1) == 0)
+        {
+            const int vcols = bcols >> 1;
+
+            GpuMat vsrc1(src1.rows, vcols, CV_16UC1, src1.data, src1.step);
+            GpuMat vsrc2(src1.rows, vcols, CV_16UC1, src2.data, src2.step);
+            GpuMat vdst(src1.rows, vcols, CV_16UC1, dst.data, dst.step);
+
+            funcs16[op](vsrc1, vsrc2, vdst, GpuMat(), stream);
+        }
+        else
+        {
+            GpuMat vsrc1(src1.rows, bcols, CV_8UC1, src1.data, src1.step);
+            GpuMat vsrc2(src1.rows, bcols, CV_8UC1, src2.data, src2.step);
+            GpuMat vdst(src1.rows, bcols, CV_8UC1, dst.data, dst.step);
+
+            funcs8[op](vsrc1, vsrc2, vdst, GpuMat(), stream);
+        }
     }
     else
     {
-        funcs8[op](src1, src2, dst, mask, stream);
+        if (depth == CV_32F || depth == CV_32S)
+        {
+            funcs32[op](src1, src2, dst, mask, stream);
+        }
+        else if (depth == CV_16S || depth == CV_16U)
+        {
+            funcs16[op](src1, src2, dst, mask, stream);
+        }
+        else
+        {
+            funcs8[op](src1, src2, dst, mask, stream);
+        }
     }
 }
 

    _dst.create(src.size(), src.type());
    GpuMat dst = _dst.getGpuMat();

    if (depth == CV_32F || depth == CV_32S)
    {
        bitMatNot<uint>(src, dst, mask, stream);
    }
    else if (depth == CV_16S || depth == CV_16U)
    {
        bitMatNot<ushort>(src, dst, mask, stream);
    }
    else
    {
        bitMatNot<uchar>(src, dst, mask, stream);
    }
}


//////////////////////////////////////////////////////////////////////////////
/// bitwise_not

void cv::cuda::bitwise_not(InputArray _src, OutputArray _dst, InputArray _mask, Stream& stream)
{
    GpuMat src = _src.getGpuMat();
