[llvm] [GlobalISel][AArch64] Generate ptrtoint/inttoptr as opposed to bitcast in unmerge combine. (PR #115225)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 6 15:08:15 PST 2024


================
@@ -1218,8 +1218,14 @@ class LegalizationArtifactCombiner {
     } else {
       LLT MergeSrcTy = MRI.getType(MergeI->getOperand(1).getReg());
 
-      if (!ConvertOp && DestTy != MergeSrcTy)
-        ConvertOp = TargetOpcode::G_BITCAST;
+      if (!ConvertOp && DestTy != MergeSrcTy) {
+        if (DestTy.isPointer())
+          ConvertOp = TargetOpcode::G_INTTOPTR;
+        else if (MergeSrcTy.isPointer())
+          ConvertOp = TargetOpcode::G_PTRTOINT;
+        else
+          ConvertOp = TargetOpcode::G_BITCAST;
----------------
arsenm wrote:

I swear we have this exact code somewhere already 

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


More information about the llvm-commits mailing list