[llvm-branch-commits] [llvm] AMDGPU/GlobalISel: Bitcasting G_TRUNC combine (PR #217634)

Petar Avramovic via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Sep 2 02:49:15 PDT 2026


================
@@ -255,6 +255,17 @@ def combine_or_s64_s32 : GICombineRule<
          (G_OR $or, $x_lo, $y),
          (G_MERGE_VALUES $dst, $or, $x_hi))>;
 
+// (bitcast (trunc i32:$src)) -> (trunc i32:$src) with the bitcast result type.
+// Both are scalars of the same size, so only the LLT kind differs; keeping the
+// trunc alone lets matchers that look through a trunc chain still fire.
+def bitcast_of_trunc : GICombineRule<
----------------
petar-avramovic wrote:

No s32/s16 here. It is mixed integer float G_TRUNC. We are making, for example, the
`%1:sgpr(f16) = G_TRUNC %13(i32)` 

which we inherited from switching to extending LLTs on the old LLT::scalar style TRUNC 
`%1:sgpr(s16) = G_TRUNC %13(s32)` 

Argument lowering still creates the "mixed type" G_TRUNC, but in general different steps on lowering would create %9:sgpr(i16) = G_TRUNC %13(i32) and %1:sgpr(f16) = G_BITCAST %9(i16) independently.
Inst select still expects "old style G_TRUNC" and does not expects bitcasts.

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


More information about the llvm-branch-commits mailing list