[FastISel][ARM] Fall-back to constant pool loads when materializing an i32 constant.
authorJuergen Ributzka <juergen@apple.com>
Thu, 14 Aug 2014 23:29:49 +0000 (23:29 +0000)
committerJuergen Ributzka <juergen@apple.com>
Thu, 14 Aug 2014 23:29:49 +0000 (23:29 +0000)
FastEmit_i won't always succeed to materialize an i32 constant and just fail.
This would trigger a fall-back to SelectionDAG, which is really not necessary.

This fix will first fall-back to a constant pool load to materialize the constant
before giving up for good.

This fixes <rdar://problem/18022633>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215682 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMFastISel.cpp
test/CodeGen/ARM/fast-isel-mvn.ll

index 5cb6d9a0a779dd4ada5eb0953b183cb84cecec52..a6c51982bd19fb73ab4098f35856df220a4c01eb 100644 (file)
@@ -547,7 +547,8 @@ unsigned ARMFastISel::ARMMaterializeInt(const Constant *C, MVT VT) {
   }
 
   if (Subtarget->useMovt(*FuncInfo.MF))
-    return FastEmit_i(VT, VT, ISD::Constant, CI->getZExtValue());
+    if (FastEmit_i(VT, VT, ISD::Constant, CI->getZExtValue()))
+      return true;
 
   // Load from constant pool.  For now 32-bit only.
   if (VT != MVT::i32)
index 9cb56ea9ae13c0d31d241a852501d6d1b1f55678..c9c32880cceca3a91da054b343630150a2b3938f 100644 (file)
@@ -106,3 +106,15 @@ entry:
   call void @foo(i32 -2130706433)
   ret void
 }
+
+; Load from constant pool.
+define i32 @t10(i32 %a) {
+; ARM-LABEL:   t10
+; ARM:         ldr
+; THUMB-LABEL: t10
+; THUMB:       movw r1, #52257
+; THUMB-NEXT:  movt r1, #35037
+  %1 = xor i32 -1998730207, %a
+  ret i32 %1
+}
+