Skip to content

Conversation

@V-FEXrt
Copy link
Collaborator

@V-FEXrt V-FEXrt commented Dec 15, 2025

Fixes #7915

There is a detailed writeup in the issue but in summary, native vectors in SM6.9 shouldn't be optimized in the way this path enables and weren't cleanly being rejected. This change now rejects them

Copy link
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned in the issue here:
I don't understand why vectors should come into play at all, unless there's another bug. Why would you expect to add up the mantissa bits from multiple scalars in a vector to see if it's representable by a scalar int type? Am I missing something?

In the issue:

MinBW for a float2 is 65 so it fails the check and early exits as expected.

But what if it were half? Why is the vector size relevant at all for what should be a scalar transformation?

@V-FEXrt
Copy link
Collaborator Author

V-FEXrt commented Dec 16, 2025

But what if it were half?

For half2 both with and without -enable-16bit-types MinBW is 66 (turns out float2 is also 66 and I had a typo initially)

@tex3d
Copy link
Contributor

tex3d commented Dec 17, 2025

I mentioned in the issue here: I don't understand why vectors should come into play at all, unless there's another bug. Why would you expect to add up the mantissa bits from multiple scalars in a vector to see if it's representable by a scalar int type? Am I missing something?

In the issue:

MinBW for a float2 is 65 so it fails the check and early exits as expected.

But what if it were half? Why is the vector size relevant at all for what should be a scalar transformation?

Ok, so I had mistakenly thought we were adding up mantissa bit widths or something. The real issue is that the pass can't handle vectors at all, breaking when calling getFltSemantics on a vector type. So we should just skip them in findRoots. That's one of the changes to the upstream version of this pass.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 2b90cd383384366273ba2e84edd48630e974acfd bdcbe891f5025e63c1df6d4e06e455f7179dd0bd -- lib/Transforms/Scalar/Float2Int.cpp
View the diff from clang-format here.
diff --git a/lib/Transforms/Scalar/Float2Int.cpp b/lib/Transforms/Scalar/Float2Int.cpp
index 8cbe3895..e3beb07b 100644
--- a/lib/Transforms/Scalar/Float2Int.cpp
+++ b/lib/Transforms/Scalar/Float2Int.cpp
@@ -136,7 +136,8 @@ void Float2Int::findRoots(Function &F, SmallPtrSet<Instruction*,8> &Roots) {
       if (isa<VectorType>(I.getType()))
         continue;
       switch (I.getOpcode()) {
-      default: break;
+      default:
+        break;
       case Instruction::FPToUI:
       case Instruction::FPToSI:
         Roots.insert(&I);
  • Check this box to apply formatting changes to this branch.

Copy link
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the right fix!

@V-FEXrt V-FEXrt merged commit f42c225 into microsoft:main Dec 17, 2025
10 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in HLSL Roadmap Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Invalid floating type error when compiling shader

4 participants