summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG/ARM
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG/ARM')
-rw-r--r--llvm/test/Transforms/SimplifyCFG/ARM/cttz-ctlz.ll21
-rw-r--r--llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll17
-rw-r--r--llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table-constant-expr.ll24
-rw-r--r--llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll106
4 files changed, 144 insertions, 24 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/cttz-ctlz.ll b/llvm/test/Transforms/SimplifyCFG/ARM/cttz-ctlz.ll
index ffcf2175091..22f5e9f3cc1 100644
--- a/llvm/test/Transforms/SimplifyCFG/ARM/cttz-ctlz.ll
+++ b/llvm/test/Transforms/SimplifyCFG/ARM/cttz-ctlz.ll
@@ -1,11 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -simplifycfg -mtriple=arm -mattr=+v6t2 < %s | FileCheck %s
define i32 @ctlz(i32 %A) {
; CHECK-LABEL: @ctlz(
-; CHECK: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0
-; CHECK-NEXT: [[CTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true)
-; CHECK-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i32 32, i32 [[CTZ]]
-; CHECK-NEXT: ret i32 [[SEL]]
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.ctlz.i32(i32 [[A]], i1 true)
+; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[TOBOOL]], i32 32, i32 [[TMP0]]
+; CHECK-NEXT: ret i32 [[SPEC_SELECT]]
+;
entry:
%tobool = icmp eq i32 %A, 0
br i1 %tobool, label %cond.end, label %cond.true
@@ -21,10 +24,12 @@ cond.end:
define i32 @cttz(i32 %A) {
; CHECK-LABEL: @cttz(
-; CHECK: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0
-; CHECK-NEXT: [[CTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %A, i1 true)
-; CHECK-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i32 32, i32 [[CTZ]]
-; CHECK-NEXT: ret i32 [[SEL]]
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[A:%.*]], 0
+; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.cttz.i32(i32 [[A]], i1 true)
+; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[TOBOOL]], i32 32, i32 [[TMP0]]
+; CHECK-NEXT: ret i32 [[SPEC_SELECT]]
+;
entry:
%tobool = icmp eq i32 %A, 0
br i1 %tobool, label %cond.end, label %cond.true
diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll b/llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll
index 9484de77db4..9218ee185b1 100644
--- a/llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll
+++ b/llvm/test/Transforms/SimplifyCFG/ARM/select-trunc-i64.ll
@@ -1,11 +1,20 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
;RUN: opt -S -simplifycfg -mtriple=arm < %s | FileCheck %s
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-; CHECK-LABEL: select_trunc_i64
-; CHECK-NOT: br
-; CHECK: select
-; CHECK: select
define arm_aapcscc i32 @select_trunc_i64(i32 %a, i32 %b) {
+; CHECK-LABEL: @select_trunc_i64(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[A:%.*]] to i64
+; CHECK-NEXT: [[CONV1:%.*]] = sext i32 [[B:%.*]] to i64
+; CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[CONV1]], [[CONV]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[ADD]], 2147483647
+; CHECK-NEXT: [[TMP0:%.*]] = icmp sgt i64 [[ADD]], -2147483648
+; CHECK-NEXT: [[COND:%.*]] = select i1 [[TMP0]], i64 [[ADD]], i64 -2147483648
+; CHECK-NEXT: [[EXTRACT_T:%.*]] = trunc i64 [[COND]] to i32
+; CHECK-NEXT: [[COND8_OFF0:%.*]] = select i1 [[CMP]], i32 2147483647, i32 [[EXTRACT_T]]
+; CHECK-NEXT: ret i32 [[COND8_OFF0]]
+;
entry:
%conv = sext i32 %a to i64
%conv1 = sext i32 %b to i64
diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table-constant-expr.ll b/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table-constant-expr.ll
index 453a7686403..f6773717342 100644
--- a/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table-constant-expr.ll
+++ b/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table-constant-expr.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -simplifycfg < %s | FileCheck %s
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
@@ -15,11 +16,28 @@ target triple = "armv7a--none-eabi"
@g4 = external thread_local global i32, align 4
define i32* @test3(i32 %n) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: switch i32 [[N:%.*]], label [[SW_DEFAULT:%.*]] [
+; CHECK-NEXT: i32 0, label [[RETURN:%.*]]
+; CHECK-NEXT: i32 1, label [[SW_BB1:%.*]]
+; CHECK-NEXT: i32 2, label [[SW_BB2:%.*]]
+; CHECK-NEXT: ]
+; CHECK: sw.bb1:
+; CHECK-NEXT: br label [[RETURN]]
+; CHECK: sw.bb2:
+; CHECK-NEXT: br label [[RETURN]]
+; CHECK: sw.default:
+; CHECK-NEXT: br label [[RETURN]]
+; CHECK: return:
+; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32* [ @g4, [[SW_DEFAULT]] ], [ getelementptr inbounds (i32, i32* inttoptr (i32 mul (i32 ptrtoint (i32* @g3 to i32), i32 2) to i32*), i32 1), [[SW_BB2]] ], [ @g2, [[SW_BB1]] ], [ @g1, [[ENTRY:%.*]] ]
+; CHECK-NEXT: ret i32* [[RETVAL_0]]
+;
entry:
switch i32 %n, label %sw.default [
- i32 0, label %sw.bb
- i32 1, label %sw.bb1
- i32 2, label %sw.bb2
+ i32 0, label %sw.bb
+ i32 1, label %sw.bb1
+ i32 2, label %sw.bb2
]
sw.bb:
diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll b/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
index 501bc31bd0d..b6573de4975 100644
--- a/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
+++ b/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -simplifycfg -switch-to-lookup -mtriple=arm -relocation-model=static < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ENABLE
; RUN: opt -S -simplifycfg -switch-to-lookup -mtriple=arm -relocation-model=pic < %s | FileCheck %s --check-prefix=CHECK --check-prefix=ENABLE
; RUN: opt -S -simplifycfg -switch-to-lookup -mtriple=arm -relocation-model=ropi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLE
@@ -22,11 +23,22 @@ target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "armv7a--none-eabi"
define i32 @test1(i32 %n) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[N:%.*]], 3
+; CHECK-NEXT: br i1 [[TMP0]], label [[SWITCH_LOOKUP:%.*]], label [[RETURN:%.*]]
+; CHECK: switch.lookup:
+; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.test1, i32 0, i32 [[N]]
+; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i32, i32* [[SWITCH_GEP]]
+; CHECK-NEXT: ret i32 [[SWITCH_LOAD]]
+; CHECK: return:
+; CHECK-NEXT: ret i32 15498
+;
entry:
switch i32 %n, label %sw.default [
- i32 0, label %sw.bb
- i32 1, label %sw.bb1
- i32 2, label %sw.bb2
+ i32 0, label %sw.bb
+ i32 1, label %sw.bb1
+ i32 2, label %sw.bb2
]
sw.bb:
@@ -53,11 +65,39 @@ return:
define i32* @test2(i32 %n) {
+; ENABLE-LABEL: @test2(
+; ENABLE-NEXT: entry:
+; ENABLE-NEXT: [[TMP0:%.*]] = icmp ult i32 [[N:%.*]], 3
+; ENABLE-NEXT: br i1 [[TMP0]], label [[SWITCH_LOOKUP:%.*]], label [[RETURN:%.*]]
+; ENABLE: switch.lookup:
+; ENABLE-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x i32*], [3 x i32*]* @switch.table.test2, i32 0, i32 [[N]]
+; ENABLE-NEXT: [[SWITCH_LOAD:%.*]] = load i32*, i32** [[SWITCH_GEP]]
+; ENABLE-NEXT: ret i32* [[SWITCH_LOAD]]
+; ENABLE: return:
+; ENABLE-NEXT: ret i32* @c4
+;
+; DISABLE-LABEL: @test2(
+; DISABLE-NEXT: entry:
+; DISABLE-NEXT: switch i32 [[N:%.*]], label [[SW_DEFAULT:%.*]] [
+; DISABLE-NEXT: i32 0, label [[RETURN:%.*]]
+; DISABLE-NEXT: i32 1, label [[SW_BB1:%.*]]
+; DISABLE-NEXT: i32 2, label [[SW_BB2:%.*]]
+; DISABLE-NEXT: ]
+; DISABLE: sw.bb1:
+; DISABLE-NEXT: br label [[RETURN]]
+; DISABLE: sw.bb2:
+; DISABLE-NEXT: br label [[RETURN]]
+; DISABLE: sw.default:
+; DISABLE-NEXT: br label [[RETURN]]
+; DISABLE: return:
+; DISABLE-NEXT: [[RETVAL_0:%.*]] = phi i32* [ @c4, [[SW_DEFAULT]] ], [ @c3, [[SW_BB2]] ], [ @c2, [[SW_BB1]] ], [ @c1, [[ENTRY:%.*]] ]
+; DISABLE-NEXT: ret i32* [[RETVAL_0]]
+;
entry:
switch i32 %n, label %sw.default [
- i32 0, label %sw.bb
- i32 1, label %sw.bb1
- i32 2, label %sw.bb2
+ i32 0, label %sw.bb
+ i32 1, label %sw.bb1
+ i32 2, label %sw.bb2
]
sw.bb:
@@ -83,11 +123,39 @@ return:
@g4 = external global i32, align 4
define i32* @test3(i32 %n) {
+; ENABLE-LABEL: @test3(
+; ENABLE-NEXT: entry:
+; ENABLE-NEXT: [[TMP0:%.*]] = icmp ult i32 [[N:%.*]], 3
+; ENABLE-NEXT: br i1 [[TMP0]], label [[SWITCH_LOOKUP:%.*]], label [[RETURN:%.*]]
+; ENABLE: switch.lookup:
+; ENABLE-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x i32*], [3 x i32*]* @switch.table.test3, i32 0, i32 [[N]]
+; ENABLE-NEXT: [[SWITCH_LOAD:%.*]] = load i32*, i32** [[SWITCH_GEP]]
+; ENABLE-NEXT: ret i32* [[SWITCH_LOAD]]
+; ENABLE: return:
+; ENABLE-NEXT: ret i32* @g4
+;
+; DISABLE-LABEL: @test3(
+; DISABLE-NEXT: entry:
+; DISABLE-NEXT: switch i32 [[N:%.*]], label [[SW_DEFAULT:%.*]] [
+; DISABLE-NEXT: i32 0, label [[RETURN:%.*]]
+; DISABLE-NEXT: i32 1, label [[SW_BB1:%.*]]
+; DISABLE-NEXT: i32 2, label [[SW_BB2:%.*]]
+; DISABLE-NEXT: ]
+; DISABLE: sw.bb1:
+; DISABLE-NEXT: br label [[RETURN]]
+; DISABLE: sw.bb2:
+; DISABLE-NEXT: br label [[RETURN]]
+; DISABLE: sw.default:
+; DISABLE-NEXT: br label [[RETURN]]
+; DISABLE: return:
+; DISABLE-NEXT: [[RETVAL_0:%.*]] = phi i32* [ @g4, [[SW_DEFAULT]] ], [ @g3, [[SW_BB2]] ], [ @g2, [[SW_BB1]] ], [ @g1, [[ENTRY:%.*]] ]
+; DISABLE-NEXT: ret i32* [[RETVAL_0]]
+;
entry:
switch i32 %n, label %sw.default [
- i32 0, label %sw.bb
- i32 1, label %sw.bb1
- i32 2, label %sw.bb2
+ i32 0, label %sw.bb
+ i32 1, label %sw.bb1
+ i32 2, label %sw.bb2
]
sw.bb:
@@ -114,6 +182,26 @@ declare i32 @f4(i32, i32)
declare i32 @f5(i32, i32)
define i32 @test4(i32 %a, i32 %b, i32 %c) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: switch i32 [[A:%.*]], label [[COND_FALSE6:%.*]] [
+; CHECK-NEXT: i32 1, label [[COND_END11:%.*]]
+; CHECK-NEXT: i32 2, label [[COND_END11_FOLD_SPLIT:%.*]]
+; CHECK-NEXT: i32 3, label [[COND_END11_FOLD_SPLIT1:%.*]]
+; CHECK-NEXT: ]
+; CHECK: cond.false6:
+; CHECK-NEXT: [[CMP7:%.*]] = icmp eq i32 [[A]], 4
+; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP7]], i32 (i32, i32)* @f4, i32 (i32, i32)* @f5
+; CHECK-NEXT: br label [[COND_END11]]
+; CHECK: cond.end11.fold.split:
+; CHECK-NEXT: br label [[COND_END11]]
+; CHECK: cond.end11.fold.split1:
+; CHECK-NEXT: br label [[COND_END11]]
+; CHECK: cond.end11:
+; CHECK-NEXT: [[COND12:%.*]] = phi i32 (i32, i32)* [ @f1, [[ENTRY:%.*]] ], [ [[COND]], [[COND_FALSE6]] ], [ @f2, [[COND_END11_FOLD_SPLIT]] ], [ @f3, [[COND_END11_FOLD_SPLIT1]] ]
+; CHECK-NEXT: [[CALL:%.*]] = call i32 [[COND12]](i32 [[B:%.*]], i32 [[C:%.*]])
+; CHECK-NEXT: ret i32 [[CALL]]
+;
entry:
%cmp = icmp eq i32 %a, 1
br i1 %cmp, label %cond.end11, label %cond.false
OpenPOWER on IntegriCloud