Index: llvm/lib/Target/ARM/ARMSubtarget.cpp =================================================================== --- llvm/lib/Target/ARM/ARMSubtarget.cpp +++ llvm/lib/Target/ARM/ARMSubtarget.cpp @@ -235,9 +235,12 @@ if (isTargetMachO() && isTargetIOS() && getTargetTriple().isOSVersionLT(5, 0)) SupportsTailCall = false; + // Multi-instruction IT Blocks have been deprecated in ARMv8, additionally + // Windows does not permit them, even for older ARM versions. + switch (IT) { case DefaultIT: - RestrictIT = hasV8Ops() && !hasMinSize(); + RestrictIT = (hasV8Ops() && !hasMinSize()) || isTargetWindows(); break; case RestrictedIT: RestrictIT = true; Index: llvm/test/CodeGen/ARM/restrict-it-minsize.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/ARM/restrict-it-minsize.ll @@ -0,0 +1,29 @@ +; RUN: llc < %s -mtriple=thumbv7-linux-gnueabihf | FileCheck %s +; RUN: llc < %s -mtriple=thumbv8-linux-gnueabihf | FileCheck %s +; RUN: llc < %s -mtriple=thumbv7-pc-windows-msvc | FileCheck %s --check-prefix=CHECK-RESTRICTIT +; RUN: llc < %s -mtriple=thumbv8-pc-windows-msvc | FileCheck %s --check-prefix=CHECK-RESTRICTIT + +; Verifies that IT blocks are unrestricted when optimizing for size, except on Windows. + +define i32 @bundled_instruction(i32* %addr, i32** %addr2, i1 %tst) minsize optsize { +; CHECK-LABEL: bundled_instruction: +; CHECK: itee ne +; CHECK: movne r0, #0 +; CHECK: ldmeq r3!, {r0} +; CHECK: streq r3, [r1] +; CHECK-RESTRICTIT: beq {{.+}}0_2 +; CHECK-RESTRICTIT: movs r0, #0 +; CHECK-RESTRICTIT: {{.+}}0_2: +; CHECK-RESTRICTIT: ldm r3!, {r0} +; CHECK-RESTRICTIT: str r3, [r1] + br i1 %tst, label %true, label %false + +true: + ret i32 0 + +false: + %res = load i32, i32* %addr, align 4 + %next = getelementptr i32, i32* %addr, i32 1 + store i32* %next, i32** %addr2 + ret i32 %res +} Index: llvm/test/CodeGen/ARM/restrict-it.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/ARM/restrict-it.ll @@ -0,0 +1,29 @@ +; RUN: llc < %s -mtriple=thumbv7-linux-gnueabihf | FileCheck %s +; RUN: llc < %s -mtriple=thumbv8-linux-gnueabihf | FileCheck %s --check-prefix=CHECK-RESTRICTIT +; RUN: llc < %s -mtriple=thumbv7-pc-windows-msvc | FileCheck %s --check-prefix=CHECK-RESTRICTIT +; RUN: llc < %s -mtriple=thumbv8-pc-windows-msvc | FileCheck %s --check-prefix=CHECK-RESTRICTIT + +; Verifies that restricted IT blocks are enabled for v8, and always on Windows. + +define i32 @bundled_instruction(i32* %addr, i32** %addr2, i1 %tst) { +; CHECK-LABEL: bundled_instruction: +; CHECK: itee ne +; CHECK: movne r0, #0 +; CHECK: ldreq r0, [r3], #4 +; CHECK: streq r3, [r1] +; CHECK-RESTRICTIT: beq {{.+}}0_2 +; CHECK-RESTRICTIT: movs r0, #0 +; CHECK-RESTRICTIT: {{.+}}0_2: +; CHECK-RESTRICTIT: ldr r0, [r3], #4 +; CHECK-RESTRICTIT: str r3, [r1] + br i1 %tst, label %true, label %false + +true: + ret i32 0 + +false: + %res = load i32, i32* %addr, align 4 + %next = getelementptr i32, i32* %addr, i32 1 + store i32* %next, i32** %addr2 + ret i32 %res +}