[llvm] d4225b8 - [NFC][SimplifyCFG] Add some more tests for Arm.
Sam Parker via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 03:46:25 PDT 2020
Author: Sam Parker
Date: 2020-08-25T11:44:17+01:00
New Revision: d4225b8f17d817a544b50d5e54737b059c660110
URL: https://github.com/llvm/llvm-project/commit/d4225b8f17d817a544b50d5e54737b059c660110
DIFF: https://github.com/llvm/llvm-project/commit/d4225b8f17d817a544b50d5e54737b059c660110.diff
LOG: [NFC][SimplifyCFG] Add some more tests for Arm.
Added:
Modified:
llvm/test/Transforms/SimplifyCFG/ARM/branch-fold-threshold.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/branch-fold-threshold.ll b/llvm/test/Transforms/SimplifyCFG/ARM/branch-fold-threshold.ll
index 370c6052fab5..c37cfe28dc2b 100644
--- a/llvm/test/Transforms/SimplifyCFG/ARM/branch-fold-threshold.ll
+++ b/llvm/test/Transforms/SimplifyCFG/ARM/branch-fold-threshold.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -mtriple=thumbv8m.main %s -simplifycfg -S | FileCheck %s
-; RUN: opt -mtriple=thumbv8a %s -simplifycfg -S | FileCheck %s
+; RUN: opt -mtriple=thumbv8m.main %s -simplifycfg -S | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB
+; RUN: opt -mtriple=thumbv8a %s -simplifycfg -S | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB
+; RUN: opt -mtriple=armv8a %s -simplifycfg -S | FileCheck %s --check-prefix=CHECK --check-prefix=ARM
define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) {
; CHECK-LABEL: @foo(
@@ -101,4 +102,136 @@ cond.end:
ret i32 %cond
}
+define i32 @or_predicate(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) {
+; CHECK-LABEL: @or_predicate(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[D:%.*]], 3
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[C:%.*]], [[A:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[ADD]], [[B:%.*]]
+; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP]], [[CMP1]]
+; CHECK-NEXT: br i1 [[OR_COND]], label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
+; CHECK: cond.false:
+; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[INPUT:%.*]], align 4
+; CHECK-NEXT: br label [[COND_END]]
+; CHECK: cond.end:
+; CHECK-NEXT: [[COND:%.*]] = phi i32 [ [[TMP0]], [[COND_FALSE]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT: ret i32 [[COND]]
+;
+entry:
+ %cmp = icmp sgt i32 %d, 3
+ br i1 %cmp, label %cond.end, label %lor.lhs.false
+
+lor.lhs.false:
+ %add = add nsw i32 %c, %a
+ %cmp1 = icmp slt i32 %add, %b
+ br i1 %cmp1, label %cond.end, label %cond.false
+
+cond.false:
+ %0 = load i32, i32* %input, align 4
+ br label %cond.end
+
+cond.end:
+ %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ], [ 0, %entry ]
+ ret i32 %cond
+}
+
+define i32 @or_invert_predicate(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) {
+; CHECK-LABEL: @or_invert_predicate(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[D:%.*]], 3
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[C:%.*]], [[A:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[ADD]], [[B:%.*]]
+; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP]], [[CMP1]]
+; CHECK-NEXT: br i1 [[OR_COND]], label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
+; CHECK: cond.false:
+; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[INPUT:%.*]], align 4
+; CHECK-NEXT: br label [[COND_END]]
+; CHECK: cond.end:
+; CHECK-NEXT: [[COND:%.*]] = phi i32 [ [[TMP0]], [[COND_FALSE]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT: ret i32 [[COND]]
+;
+entry:
+ %cmp = icmp sgt i32 %d, 3
+ br i1 %cmp, label %lor.lhs.false, label %cond.end
+
+lor.lhs.false:
+ %add = add nsw i32 %c, %a
+ %cmp1 = icmp slt i32 %add, %b
+ br i1 %cmp1, label %cond.end, label %cond.false
+
+cond.false:
+ %0 = load i32, i32* %input, align 4
+ br label %cond.end
+
+cond.end:
+ %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ], [ 0, %entry ]
+ ret i32 %cond
+}
+
+define i32 @or_predicate_minsize(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) #0 {
+; CHECK-LABEL: @or_predicate_minsize(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[D:%.*]], 3
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[C:%.*]], [[A:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[ADD]], [[B:%.*]]
+; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP]], [[CMP1]]
+; CHECK-NEXT: br i1 [[OR_COND]], label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
+; CHECK: cond.false:
+; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[INPUT:%.*]], align 4
+; CHECK-NEXT: br label [[COND_END]]
+; CHECK: cond.end:
+; CHECK-NEXT: [[COND:%.*]] = phi i32 [ [[TMP0]], [[COND_FALSE]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT: ret i32 [[COND]]
+;
+entry:
+ %cmp = icmp sgt i32 %d, 3
+ br i1 %cmp, label %cond.end, label %lor.lhs.false
+
+lor.lhs.false:
+ %add = add nsw i32 %c, %a
+ %cmp1 = icmp slt i32 %add, %b
+ br i1 %cmp1, label %cond.end, label %cond.false
+
+cond.false:
+ %0 = load i32, i32* %input, align 4
+ br label %cond.end
+
+cond.end:
+ %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ], [ 0, %entry ]
+ ret i32 %cond
+}
+
+define i32 @or_invert_predicate_minsize(i32 %a, i32 %b, i32 %c, i32 %d, i32* %input) #0 {
+; CHECK-LABEL: @or_invert_predicate_minsize(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[D:%.*]], 3
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[C:%.*]], [[A:%.*]]
+; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[ADD]], [[B:%.*]]
+; CHECK-NEXT: [[OR_COND:%.*]] = or i1 [[CMP]], [[CMP1]]
+; CHECK-NEXT: br i1 [[OR_COND]], label [[COND_END:%.*]], label [[COND_FALSE:%.*]]
+; CHECK: cond.false:
+; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[INPUT:%.*]], align 4
+; CHECK-NEXT: br label [[COND_END]]
+; CHECK: cond.end:
+; CHECK-NEXT: [[COND:%.*]] = phi i32 [ [[TMP0]], [[COND_FALSE]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-NEXT: ret i32 [[COND]]
+;
+entry:
+ %cmp = icmp sgt i32 %d, 3
+ br i1 %cmp, label %lor.lhs.false, label %cond.end
+
+lor.lhs.false:
+ %add = add nsw i32 %c, %a
+ %cmp1 = icmp slt i32 %add, %b
+ br i1 %cmp1, label %cond.end, label %cond.false
+
+cond.false:
+ %0 = load i32, i32* %input, align 4
+ br label %cond.end
+
+cond.end:
+ %cond = phi i32 [ %0, %cond.false ], [ 0, %lor.lhs.false ], [ 0, %entry ]
+ ret i32 %cond
+}
+
attributes #0 = { minsize optsize }
More information about the llvm-commits
mailing list