Index: lib/Target/ARM/ARM.td =================================================================== --- lib/Target/ARM/ARM.td +++ lib/Target/ARM/ARM.td @@ -154,6 +154,9 @@ "Generate calls via indirect call " "instructions">; +def FeatureDontUseMovt : SubtargetFeature<"dont-use-movt", "DontUseMovt", + "true", "Don't use movt">; + // ARM ISAs. def HasV4TOps : SubtargetFeature<"v4t", "HasV4TOps", "true", "Support ARM v4T instructions">; Index: lib/Target/ARM/ARMSubtarget.h =================================================================== --- lib/Target/ARM/ARMSubtarget.h +++ lib/Target/ARM/ARMSubtarget.h @@ -112,9 +112,9 @@ /// IsR9Reserved - True if R9 is a not available as general purpose register. bool IsR9Reserved; - /// UseMovt - True if MOVT / MOVW pairs are used for materialization of 32-bit - /// imms (including global addresses). - bool UseMovt; + /// DontUseMovt - True if MOVT / MOVW pairs are not used for materialization + /// of 32-bit imms (including global addresses). + bool DontUseMovt; /// SupportsTailCall - True if the OS supports tail call. The dynamic linker /// must be able to synthesize call stubs for interworking between ARM and Index: lib/Target/ARM/ARMSubtarget.cpp =================================================================== --- lib/Target/ARM/ARMSubtarget.cpp +++ lib/Target/ARM/ARMSubtarget.cpp @@ -44,9 +44,6 @@ cl::desc("Reserve R9, making it unavailable as GPR")); static cl::opt -ArmUseMOVT("arm-use-movt", cl::init(true), cl::Hidden); - -static cl::opt UseFusedMulOps("arm-use-mulops", cl::init(true), cl::Hidden); @@ -149,7 +146,7 @@ HasThumb2 = false; NoARM = false; IsR9Reserved = ReserveR9; - UseMovt = false; + DontUseMovt = false; SupportsTailCall = false; HasFP16 = false; HasD16 = false; @@ -216,8 +213,6 @@ if (isTargetNaCl()) stackAlignment = 16; - UseMovt = hasV6T2Ops() && ArmUseMOVT; - if (isTargetMachO()) { IsR9Reserved = ReserveR9 || !HasV6Ops; SupportsTailCall = !isTargetIOS() || !getTargetTriple().isOSVersionLT(5, 0); @@ -338,8 +333,9 @@ // NOTE Windows on ARM needs to use mov.w/mov.t pairs to materialise 32-bit // immediates as it is inherently position independent, and may be out of // range otherwise. - return UseMovt && (isTargetWindows() || - !MF.getFunction()->hasFnAttribute(Attribute::MinSize)); + return !DontUseMovt && hasV6T2Ops() && + (isTargetWindows() || + !MF.getFunction()->hasFnAttribute(Attribute::MinSize)); } bool ARMSubtarget::useFastISel() const { Index: test/CodeGen/ARM/fast-isel-mvn.ll =================================================================== --- test/CodeGen/ARM/fast-isel-mvn.ll +++ test/CodeGen/ARM/fast-isel-mvn.ll @@ -1,8 +1,8 @@ -; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -arm-use-movt=false -mtriple=armv7-apple-ios < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM -; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -arm-use-movt=false -mtriple=armv7-linux-gnueabi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM -; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -arm-use-movt=false -mtriple=thumbv7-apple-ios < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM -; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -arm-use-movt=true -mtriple=thumbv7-apple-ios < %s | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB -; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -arm-use-movt=true -mtriple=armv7-apple-ios < %s | FileCheck %s --check-prefix=MOVT +; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mattr=+dont-use-movt -mtriple=armv7-apple-ios < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM +; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mattr=+dont-use-movt -mtriple=armv7-linux-gnueabi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM +; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mattr=+dont-use-movt -mtriple=thumbv7-apple-ios < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ARM +; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-ios < %s | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB +; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort=1 -relocation-model=dynamic-no-pic -mtriple=armv7-apple-ios < %s | FileCheck %s --check-prefix=MOVT ; rdar://10412592 define void @t1() nounwind { Index: test/CodeGen/ARM/subtarget-features-dont-use-movt.ll =================================================================== --- /dev/null +++ test/CodeGen/ARM/subtarget-features-dont-use-movt.ll @@ -0,0 +1,45 @@ +; RUN: llc -march thumb -mcpu=cortex-a8 -relocation-model=static %s -o - | FileCheck -check-prefix=NO-OPTION %s +; RUN: llc -march thumb -mcpu=cortex-a8 -relocation-model=static %s -o - -mattr=-dont-use-movt | FileCheck -check-prefix=USE-MOVT %s +; RUN: llc -march thumb -mcpu=cortex-a8 -relocation-model=static %s -o - -mattr=+dont-use-movt | FileCheck -check-prefix=NO-USE-MOVT %s +; RUN: llc -march thumb -mcpu=cortex-a8 -relocation-model=static %s -o - -O0 | FileCheck -check-prefix=NO-OPTION %s +; RUN: llc -march thumb -mcpu=cortex-a8 -relocation-model=static %s -o - -O0 -mattr=-dont-use-movt | FileCheck -check-prefix=USE-MOVT %s +; RUN: llc -march thumb -mcpu=cortex-a8 -relocation-model=static %s -o - -O0 -mattr=+dont-use-movt | FileCheck -check-prefix=NO-USE-MOVT %s + +; NO-OPTION-LABEL: {{_?}}foo0 +; NO-OPTION: ldr [[R0:r[0-9]+]], [[L0:.*]] +; NO-OPTION: [[L0]]: +; NO-OPTION: .long 2296237089 + +; USE-MOVT-LABEL: {{_?}}foo0 +; USE-MOVT: movw [[R0:r[0-9]+]], #52257 +; USE-MOVT: movt [[R0]], #35037 + +; NO-USE-MOVT-LABEL: {{_?}}foo0 +; NO-USE-MOVT: ldr [[R0:r[0-9]+]], [[L0:.*]] +; NO-USE-MOVT: [[L0]]: +; NO-USE-MOVT: .long 2296237089 + +define i32 @foo0(i32 %a) #0 { + %1 = xor i32 -1998730207, %a + ret i32 %1 +} + +; NO-OPTION-LABEL: {{_?}}foo1 +; NO-OPTION: movw [[R0:r[0-9]+]], #52257 +; NO-OPTION: movt [[R0]], #35037 + +; USE-MOVT-LABEL: {{_?}}foo1 +; USE-MOVT: movw [[R0:r[0-9]+]], #52257 +; USE-MOVT: movt [[R0]], #35037 + +; NO-USE-MOVT-LABEL: {{_?}}foo1 +; NO-USE-MOVT: ldr [[R0:r[0-9]+]], [[L0:.*]] +; NO-USE-MOVT: [[L0]]: +; NO-USE-MOVT: .long 2296237089 + +define i32 @foo1(i32 %a) { + %1 = xor i32 -1998730207, %a + ret i32 %1 +} + +attributes #0 = { "target-features"="+dont-use-movt" }