spread(struct brw_reg reg, unsigned s)
 {
    if (s) {
-      assert(_mesa_is_pow_two(s));
+      assert(util_is_power_of_two_nonzero(s));
 
       if (reg.hstride)
          reg.hstride += cvt(s) - 1;
 
           *
           * where they pack the four bytes from the low and high four DW.
           */
-         assert(_mesa_is_pow_two(dst.writemask) &&
-                dst.writemask != 0);
+         assert(util_is_power_of_two_nonzero(dst.writemask));
          unsigned offset = __builtin_ctz(dst.writemask);
 
          dst.type = BRW_REGISTER_TYPE_UB;
 
    y_scale = samples / x_scale;
 
    /* We expect only power of 2 samples in source multisample buffer. */
-   assert(samples > 0 && _mesa_is_pow_two(samples));
+   assert(samples > 0 && util_is_power_of_two_nonzero(samples));
    while (samples >> (shader_offset + 1)) {
       shader_offset++;
    }
    }
 
    /* We expect only power of 2 samples in source multisample buffer. */
-   assert(samples > 0 && _mesa_is_pow_two(samples));
+   assert(samples > 0 && util_is_power_of_two_nonzero(samples));
    while (samples >> (shader_offset + 1)) {
       shader_offset++;
    }
           * (so the floating point exponent just gets increased), rather than
           * doing a naive sum and dividing.
           */
-         assert(_mesa_is_pow_two(samples));
+         assert(util_is_power_of_two_or_zero(samples));
          /* Fetch each individual sample. */
          sample_resolve = rzalloc_size(mem_ctx, 1);
          for (i = 0; i < samples; i++) {
 
        * Thus, I guess we need do this for other platforms as well.
        */
       if (tObj->Target == GL_TEXTURE_CUBE_MAP_ARB &&
-          !_mesa_is_pow_two(firstImage->Height))
+          !util_is_power_of_two_or_zero(firstImage->Height))
          return false;
 
       state[I915_TEXREG_SS3] = ss3;     /* SS3_NORMALIZED_COORDS */
 
        unsigned x, y;
 
         /* Swizzled surfaces must be POT  */
-       assert(_mesa_is_pow_two(dst->width) &&
-              _mesa_is_pow_two(dst->height));
+       assert(util_is_power_of_two_or_zero(dst->width) &&
+              util_is_power_of_two_or_zero(dst->height));
 
        if (context_chipset(ctx) < 0x10) {
                BEGIN_NV04(push, NV01_SUBC(SURF, OBJECT), 1);
 
        } else {
                unsigned row_align;
 
-               if (!_mesa_is_pow_two(width) || target == GL_TEXTURE_RECTANGLE) {
+               if (!util_is_power_of_two_or_zero(width) || target == GL_TEXTURE_RECTANGLE) {
                        row_align = rmesa->texture_rect_row_align - 1;
                } else if (tiling) {
                        unsigned tileWidth, tileHeight;
 
 
    if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
       /* test that mapsize is a power of two */
-      if (!_mesa_is_pow_two(mapsize)) {
+      if (!util_is_power_of_two_or_zero(mapsize)) {
         _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" );
          return;
       }
 
    if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
       /* test that mapsize is a power of two */
-      if (!_mesa_is_pow_two(mapsize)) {
+      if (!util_is_power_of_two_or_zero(mapsize)) {
         _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
          return;
       }
 
    if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
       /* test that mapsize is a power of two */
-      if (!_mesa_is_pow_two(mapsize)) {
+      if (!util_is_power_of_two_or_zero(mapsize)) {
         _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" );
          return;
       }
 
       if (width < 2 * border || width > 2 * border + maxSize)
          return GL_FALSE;
       if (!ctx->Extensions.ARB_texture_non_power_of_two) {
-         if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+         if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
             return GL_FALSE;
       }
       return GL_TRUE;
       if (height < 2 * border || height > 2 * border + maxSize)
          return GL_FALSE;
       if (!ctx->Extensions.ARB_texture_non_power_of_two) {
-         if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+         if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
             return GL_FALSE;
-         if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+         if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
             return GL_FALSE;
       }
       return GL_TRUE;
       if (depth < 2 * border || depth > 2 * border + maxSize)
          return GL_FALSE;
       if (!ctx->Extensions.ARB_texture_non_power_of_two) {
-         if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+         if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
             return GL_FALSE;
-         if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+         if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
             return GL_FALSE;
-         if (depth > 0 && !_mesa_is_pow_two(depth - 2 * border))
+         if (depth > 0 && !util_is_power_of_two_nonzero(depth - 2 * border))
             return GL_FALSE;
       }
       return GL_TRUE;
       if (height < 2 * border || height > 2 * border + maxSize)
          return GL_FALSE;
       if (!ctx->Extensions.ARB_texture_non_power_of_two) {
-         if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+         if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
             return GL_FALSE;
-         if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+         if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
             return GL_FALSE;
       }
       return GL_TRUE;
       if (height < 0 || height > ctx->Const.MaxArrayTextureLayers)
          return GL_FALSE;
       if (!ctx->Extensions.ARB_texture_non_power_of_two) {
-         if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+         if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
             return GL_FALSE;
       }
       return GL_TRUE;
       if (depth < 0 || depth > ctx->Const.MaxArrayTextureLayers)
          return GL_FALSE;
       if (!ctx->Extensions.ARB_texture_non_power_of_two) {
-         if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+         if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
             return GL_FALSE;
-         if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+         if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
             return GL_FALSE;
       }
       return GL_TRUE;
       if (level >= ctx->Const.MaxCubeTextureLevels)
          return GL_FALSE;
       if (!ctx->Extensions.ARB_texture_non_power_of_two) {
-         if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
+         if (width > 0 && !util_is_power_of_two_nonzero(width - 2 * border))
             return GL_FALSE;
-         if (height > 0 && !_mesa_is_pow_two(height - 2 * border))
+         if (height > 0 && !util_is_power_of_two_nonzero(height - 2 * border))
             return GL_FALSE;
       }
       return GL_TRUE;
 
 {
    struct swrast_texture_image *swImg = swrast_texture_image(texImage);
 
-   if ((texImage->Width == 1 || _mesa_is_pow_two(texImage->Width2)) &&
-       (texImage->Height == 1 || _mesa_is_pow_two(texImage->Height2)) &&
-       (texImage->Depth == 1 || _mesa_is_pow_two(texImage->Depth2)))
+   if ((texImage->Width == 1 || util_is_power_of_two_or_zero(texImage->Width2)) &&
+       (texImage->Height == 1 || util_is_power_of_two_or_zero(texImage->Height2)) &&
+       (texImage->Depth == 1 || util_is_power_of_two_or_zero(texImage->Depth2)))
       swImg->_IsPowerOfTwo = GL_TRUE;
    else
       swImg->_IsPowerOfTwo = GL_FALSE;
 
    }
    else {
       /* Power of two means only a single active light. */
-      if (_mesa_is_pow_two(ctx->Light._EnabledLights))
+      if (util_is_power_of_two_or_zero(ctx->Light._EnabledLights))
         tab = _tnl_light_fast_single_tab;
       else
         tab = _tnl_light_fast_tab;
 
 #endif
 }
 
-
-/**
- * Is x a power of two?
- */
-static inline int
-_mesa_is_pow_two(int x)
-{
-   return !(x & (x - 1));
-}
-
 /**
  * Round given integer to next higer power of two
  * If X is zero result is undefined.