]> granicus.if.org Git - llvm/commitdiff
GlobalISel: Add G_FCOPYSIGN
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 16 May 2019 04:08:39 +0000 (04:08 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 16 May 2019 04:08:39 +0000 (04:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360850 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/TargetOpcodes.def
include/llvm/Target/GenericOpcodes.td
lib/CodeGen/GlobalISel/IRTranslator.cpp
test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir

index cce59c37308b94e16af306ed2d7c14130496b19d..4b64756dd92b672b09b348d0721a407ace4558fa 100644 (file)
@@ -481,6 +481,12 @@ HANDLE_TARGET_OPCODE(G_UITOFP)
 /// Generic FP absolute value.
 HANDLE_TARGET_OPCODE(G_FABS)
 
+/// FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.  NOTE: This does
+/// not require that X and Y have the same type, just that they are both
+/// floating point. X and the result must have the same type.  FCOPYSIGN(f32,
+/// f64) is allowed.
+HANDLE_TARGET_OPCODE(G_FCOPYSIGN)
+
 /// Generic FP canonicalize value.
 HANDLE_TARGET_OPCODE(G_FCANONICALIZE)
 
index 1900870d6da779ec17ec47816707d1ad3c340d31..07669d2492fad5a6e18beaf1be46e84e224b30ae 100644 (file)
@@ -455,6 +455,12 @@ def G_FABS : GenericInstruction {
   let hasSideEffects = 0;
 }
 
+def G_FCOPYSIGN : GenericInstruction {
+  let OutOperandList = (outs type0:$dst);
+  let InOperandList = (ins type0:$src0, type1:$src1);
+  let hasSideEffects = 0;
+}
+
 def G_FCANONICALIZE : GenericInstruction {
   let OutOperandList = (outs type0:$dst);
   let InOperandList = (ins type0:$src);
index 939a9a92cc01d900cc2fda50ba89cafea25fecad..4ac720181edcf45dcbcdc97fd145f09636ee8b04 100644 (file)
@@ -782,6 +782,8 @@ unsigned IRTranslator::getSimpleIntrinsicOpcode(Intrinsic::ID ID) {
       return TargetOpcode::G_FEXP2;
     case Intrinsic::fabs:
       return TargetOpcode::G_FABS;
+    case Intrinsic::copysign:
+      return TargetOpcode::G_FCOPYSIGN;
     case Intrinsic::canonicalize:
       return TargetOpcode::G_FCANONICALIZE;
     case Intrinsic::floor:
index 83b5e082104169da793251082c098fe38a5e5aae..e7d1e0f5665c21efd119c7a42e5ec48ba958d290 100644 (file)
@@ -1418,6 +1418,18 @@ define float @test_fabs_intrin(float %a) {
   ret float %res
 }
 
+declare float @llvm.copysign.f32(float, float)
+define float @test_fcopysign_intrin(float %a, float %b) {
+; CHECK-LABEL: name: test_fcopysign_intrin
+; CHECK: [[A:%[0-9]+]]:_(s32) = COPY $s0
+; CHECK: [[B:%[0-9]+]]:_(s32) = COPY $s1
+; CHECK: [[RES:%[0-9]+]]:_(s32) = nnan ninf nsz arcp contract afn reassoc G_FCOPYSIGN [[A]], [[B]]
+; CHECK: $s0 = COPY [[RES]]
+
+  %res = call nnan ninf nsz arcp contract afn reassoc float @llvm.copysign.f32(float %a, float %b)
+  ret float %res
+}
+
 declare float @llvm.canonicalize.f32(float)
 define float @test_fcanonicalize_intrin(float %a) {
 ; CHECK-LABEL: name: test_fcanonicalize_intrin
index ce6743a1c7f4049675f2060ddc9e7174bcced356..088b0c00c081bcfa6dc5764e2781637919abf0a5 100644 (file)
 # DEBUG-NEXT: G_FABS (opcode {{[0-9]+}}): 1 type index
 # DEBUG:      .. type index coverage check SKIPPED: user-defined predicate detected
 #
+# DEBUG-NEXT: G_FCOPYSIGN (opcode {{[0-9]+}}): 2 type indices
+# DEBUG:      .. type index coverage check SKIPPED: no rules defined
+#
 # DEBUG-NEXT: G_FCANONICALIZE (opcode {{[0-9]+}}): 1 type index
 # DEBUG: .. type index coverage check SKIPPED: no rules defined
 #