[PATCH] D31215: [GlobalISel]: While IRTranslating intrinsic calls, for ConstantInt arguments, create a VREG

Aditya Nandakumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 14:51:08 PDT 2017


aditya_nandakumar created this revision.
Herald added subscribers: igorb, kristof.beyls, rovka, dberris.
Herald added a reviewer: javed.absar.

This patch changes the behavior of IRTranslating intrinsics where we now create VREG + G_CONSTANT for ConstantInt values. We already do this for FloatingPoint values.
The reasoning behind this is, when we have several instrinsic calls all having the same i32 constant, and when the backend is selecting the instructions, for certain instructions will not be able to use the immediate directly and will instead need to create a G_CONSTANT and use that VREG. If we have multiple calls that use the same constants, then the backend will have to de-duplicate the creation of G_CONSTANTS + selections. It'll be a lot easier for this to be done in the IRTranslator.


Repository:
  rL LLVM

https://reviews.llvm.org/D31215

Files:
  lib/CodeGen/GlobalISel/IRTranslator.cpp
  test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll


Index: test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
===================================================================
--- test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
+++ test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
@@ -467,7 +467,8 @@
 ; CHECK-LABEL: name: intrinsics
 ; CHECK: [[CUR:%[0-9]+]](s32) = COPY %w0
 ; CHECK: [[BITS:%[0-9]+]](s32) = COPY %w1
-; CHECK: [[PTR:%[0-9]+]](p0) = G_INTRINSIC intrinsic(@llvm.returnaddress), 0
+; CHECK: [[CREG:%[0-9]+]](s32) = G_CONSTANT i32 0
+; CHECK: [[PTR:%[0-9]+]](p0) = G_INTRINSIC intrinsic(@llvm.returnaddress), [[CREG]]
 ; CHECK: [[PTR_VEC:%[0-9]+]](p0) = G_FRAME_INDEX %stack.0.ptr.vec
 ; CHECK: [[VEC:%[0-9]+]](<8 x s8>) = G_LOAD [[PTR_VEC]]
 ; CHECK: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.aarch64.neon.st2), [[VEC]](<8 x s8>), [[VEC]](<8 x s8>), [[PTR]](p0)
Index: lib/CodeGen/GlobalISel/IRTranslator.cpp
===================================================================
--- lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -769,10 +769,7 @@
     // Some intrinsics take metadata parameters. Reject them.
     if (isa<MetadataAsValue>(Arg))
       return false;
-    if (ConstantInt *CI = dyn_cast<ConstantInt>(Arg))
-      MIB.addImm(CI->getSExtValue());
-    else
-      MIB.addUse(getOrCreateVReg(*Arg));
+    MIB.addUse(getOrCreateVReg(*Arg));
   }
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31215.92552.patch
Type: text/x-patch
Size: 1397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170321/16257424/attachment.bin>


More information about the llvm-commits mailing list