[PATCH] D108679: Restrict ARM IT Blocks on Windows
Daniel Paoliello via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 26 18:36:40 PDT 2021
dpaoliello updated this revision to Diff 369015.
dpaoliello added a comment.
Added tests for Restricting IT blocks for v7 vs v8, optimizing for size and Windows.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108679/new/
https://reviews.llvm.org/D108679
Files:
llvm/lib/Target/ARM/ARMSubtarget.cpp
llvm/test/CodeGen/ARM/restrict-it-minsize.ll
llvm/test/CodeGen/ARM/restrict-it.ll
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
+}
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/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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108679.369015.patch
Type: text/x-patch
Size: 3138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210827/20032110/attachment.bin>
More information about the llvm-commits
mailing list