[llvm] [GlobalISel] avoid G_TRUNC with floating-point G_MERGE_VALUES source (PR #206733)

Kacper Doga via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 2 05:51:32 PDT 2026


================
@@ -292,29 +292,40 @@ class LegalizationArtifactCombiner {
       if (!DstTy.isScalar() || !MergeSrcTy.isScalar())
         return false;
 
+      // G_TRUNC/G_MERGE_VALUES operate on the raw bit pattern - if the merge
+      // feeds us float sources, reinterpret them to integer of the same size
+      // so we never emit a G_TRUNC or G_MERGE_VALUES with a floating-point
+      // source operand.
+      const LLT WorkTy =
+          MergeSrcTy.isFloat() ? LLT::integer(MergeSrcSize) : MergeSrcTy;
+      auto AsInt = [&](Register R) {
+        if (MergeSrcTy.isFloat())
----------------
varev-dev wrote:

Thanks for review, changed condition in lambda to `MergeSrcTy != WorkTy`.

https://github.com/llvm/llvm-project/pull/206733


More information about the llvm-commits mailing list