================
@@ -148,6 +148,15 @@ template <typename T> constexpr T ldexp_impl(T X, T Exp) {
return exp2(Exp) * X;
}
+template <typename T, int Bitwidth> constexpr uint firstbithigh_impl(T X) {
+ return (Bitwidth - 1) - __builtin_hlsl_elementwise_firstbithigh(X);
+}
+
+template <typename T, int N, int Bitwidth>
+constexpr vector<uint, N> firstbithigh_impl(vector<T, N> X) {
+ return (Bitwidth - 1) - __builtin_hlsl_elementwise_firstbithigh(X);
----------------
V-FEXrt wrote:
Are we sure that DXC has divergent behavior here between DX and SPRIV? IIRC the
opcodes are divergent but the result of the hlsl intrinsic is the same
I'm trying to find proof of this right now but IIRC the DXIL ops (for high bit
only) return the number counting from the wrong side (which is why we need the
`31 - ans`) but on SPIRV they are consistent so not having the `31 - ans` is
the correct lowering
https://github.com/llvm/llvm-project/pull/166419
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits