[PATCH] D24459: [SelectionDAGBuilder] Support llvm.flt.rounds on targets where i32 is not legal

Edward Jones via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 09:03:53 PDT 2016


edward-jones created this revision.
edward-jones added a reviewer: bogner.
edward-jones added a subscriber: llvm-commits.

When creating the FLT_ROUNDS_ node, use the closest legal type to i32.

https://reviews.llvm.org/D24459

Files:
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  test/CodeGen/MSP430/flt_rounds.ll

Index: test/CodeGen/MSP430/flt_rounds.ll
===================================================================
--- /dev/null
+++ test/CodeGen/MSP430/flt_rounds.ll
@@ -0,0 +1,10 @@
+; RUN: llc -verify-machineinstrs < %s -march=msp430
+
+define i16 @foo() {
+entry:
+  %0 = call i32 @llvm.flt.rounds()
+  %1 = trunc i32 %0 to i16
+  ret i16 %1
+}
+
+declare i32 @llvm.flt.rounds() nounwind 
Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5488,10 +5488,11 @@
   case Intrinsic::gcread:
   case Intrinsic::gcwrite:
     llvm_unreachable("GC failed to lower gcread/gcwrite intrinsics!");
-  case Intrinsic::flt_rounds:
-    setValue(&I, DAG.getNode(ISD::FLT_ROUNDS_, sdl, MVT::i32));
+  case Intrinsic::flt_rounds: {
+    EVT Ty = TLI.getTypeToExpandTo(*Context, MVT::i32);
+    setValue(&I, DAG.getNode(ISD::FLT_ROUNDS_, sdl, Ty));
     return nullptr;
-
+  }
   case Intrinsic::expect: {
     // Just replace __builtin_expect(exp, c) with EXP.
     setValue(&I, getValue(I.getArgOperand(0)));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24459.71014.patch
Type: text/x-patch
Size: 1175 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160912/ba0137c4/attachment.bin>


More information about the llvm-commits mailing list