Coder Social home page Coder Social logo

Comments (6)

solidpixel avatar solidpixel commented on September 17, 2024 1

That fix is broken - it's truncating the value to 32-bits before taking the popcount.

Any reason you don't use the __builtin_popcountll() fallback, the same as __MINGW32__? I suspect that fallback could just be

#if !defined(__x86_64__)
        return static_cast<int>(__builtin_popcountll(v));
#else

from astc-encoder.

VVD avatar VVD commented on September 17, 2024 1

I'm new to this, so I did it this way.
Your patch fixed the build issue too and look better.
Thanks!

from astc-encoder.

solidpixel avatar solidpixel commented on September 17, 2024 1

Thanks for confirming - I'll get that in for 4.9.

from astc-encoder.

VVD avatar VVD commented on September 17, 2024

If, before writing the patch, I had read what the popcnt instructions do, I would have suggested the following patch:

return static_cast<int>(_mm_popcnt_u32(static_cast<uint32_t>(v)) + _mm_popcnt_u32(static_cast<uint32_t>(v >> 32)));

:-)

from astc-encoder.

VVD avatar VVD commented on September 17, 2024

Patch against main branch:

--- Source/astcenc_vecmathlib_sse_4.h.orig      2024-05-07 09:59:55 UTC
+++ Source/astcenc_vecmathlib_sse_4.h
@@ -1307,7 +1307,11 @@ ASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b)
  */
 ASTCENC_SIMD_INLINE int popcount(uint64_t v)
 {
+#if defined(__x86_64__)
        return static_cast<int>(_mm_popcnt_u64(v));
+#else
+       return static_cast<int>(__builtin_popcountll(v));
+#endif
 }

 #endif // ASTCENC_POPCNT >= 1

from astc-encoder.

solidpixel avatar solidpixel commented on September 17, 2024

Fixed on main.

from astc-encoder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.