From 266ecacfaa424a2d7c2316dd79ce4ac018f96f91 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Thu, 14 Aug 2014 23:29:49 +0000 Subject: [PATCH] [FastISel][ARM] Fall-back to constant pool loads when materializing an i32 constant. 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 . git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215682 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMFastISel.cpp | 3 ++- test/CodeGen/ARM/fast-isel-mvn.ll | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Target/ARM/ARMFastISel.cpp b/lib/Target/ARM/ARMFastISel.cpp index 5cb6d9a0a77..a6c51982bd1 100644 --- a/lib/Target/ARM/ARMFastISel.cpp +++ b/lib/Target/ARM/ARMFastISel.cpp @@ -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) diff --git a/test/CodeGen/ARM/fast-isel-mvn.ll b/test/CodeGen/ARM/fast-isel-mvn.ll index 9cb56ea9ae1..c9c32880cce 100644 --- a/test/CodeGen/ARM/fast-isel-mvn.ll +++ b/test/CodeGen/ARM/fast-isel-mvn.ll @@ -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 +} + -- 2.34.1