2019-04-17 12:52:47 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
2020-06-27 11:41:37 +08:00
|
|
|
; RUN: opt -S -make-guards-explicit -basic-aa -licm < %s | FileCheck %s
|
2019-04-17 12:52:47 +08:00
|
|
|
; RUN: opt -S -aa-pipeline=basic-aa -passes='require<opt-remark-emit>,make-guards-explicit,loop(licm)' < %s | FileCheck %s
|
|
|
|
|
|
|
|
declare void @llvm.experimental.guard(i1,...)
|
2019-11-08 23:00:55 +08:00
|
|
|
declare void @maythrow()
|
2019-04-17 12:52:47 +08:00
|
|
|
|
|
|
|
; Make sure that we do not hoist widenable_cond out of loop.
|
2019-11-08 23:00:55 +08:00
|
|
|
define void @hoist_widenable_cond(i1 %cond, i32 %N, i32 %M) {
|
|
|
|
; CHECK-LABEL: @hoist_widenable_cond(
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: entry:
|
2019-11-08 23:00:55 +08:00
|
|
|
; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: br label [[LOOP:%.*]]
|
|
|
|
; CHECK: loop:
|
|
|
|
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[GUARDED:%.*]] ]
|
|
|
|
; CHECK-NEXT: [[GUARD_COND:%.*]] = icmp slt i32 [[IV]], [[N:%.*]]
|
2019-11-08 23:00:55 +08:00
|
|
|
; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[GUARD_COND]], [[WIDENABLE_COND]]
|
|
|
|
; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
|
|
|
|
; CHECK: deopt:
|
|
|
|
; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
|
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
; CHECK: guarded:
|
|
|
|
; CHECK-NEXT: [[LOOP_COND:%.*]] = icmp slt i32 [[IV]], [[M:%.*]]
|
|
|
|
; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1
|
|
|
|
; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT:%.*]]
|
|
|
|
; CHECK: exit:
|
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
;
|
|
|
|
entry:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
loop:
|
|
|
|
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
|
|
|
|
%guard_cond = icmp slt i32 %iv, %N
|
|
|
|
call void(i1, ...) @llvm.experimental.guard(i1 %guard_cond) [ "deopt"() ]
|
|
|
|
%loop_cond = icmp slt i32 %iv, %M
|
|
|
|
%iv.next = add i32 %iv, 1
|
|
|
|
br i1 %loop_cond, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @hoist_widenable_cond_speculate(i1 %cond, i32 %N, i32 %M) {
|
|
|
|
; CHECK-LABEL: @hoist_widenable_cond_speculate(
|
|
|
|
; CHECK-NEXT: entry:
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
|
2019-11-08 23:00:55 +08:00
|
|
|
; CHECK-NEXT: br label [[LOOP:%.*]]
|
|
|
|
; CHECK: loop:
|
|
|
|
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[GUARDED:%.*]] ]
|
|
|
|
; CHECK-NEXT: [[GUARD_COND:%.*]] = icmp slt i32 [[IV]], [[N:%.*]]
|
|
|
|
; CHECK-NEXT: call void @maythrow()
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[GUARD_COND]], [[WIDENABLE_COND]]
|
|
|
|
; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
|
|
|
|
; CHECK: deopt:
|
|
|
|
; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
|
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
; CHECK: guarded:
|
|
|
|
; CHECK-NEXT: [[LOOP_COND:%.*]] = icmp slt i32 [[IV]], [[M:%.*]]
|
|
|
|
; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1
|
|
|
|
; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT:%.*]]
|
|
|
|
; CHECK: exit:
|
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
;
|
|
|
|
entry:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
loop:
|
|
|
|
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
|
|
|
|
%guard_cond = icmp slt i32 %iv, %N
|
2019-11-08 23:00:55 +08:00
|
|
|
call void @maythrow()
|
2019-04-17 12:52:47 +08:00
|
|
|
call void(i1, ...) @llvm.experimental.guard(i1 %guard_cond) [ "deopt"() ]
|
|
|
|
%loop_cond = icmp slt i32 %iv, %M
|
|
|
|
%iv.next = add i32 %iv, 1
|
|
|
|
br i1 %loop_cond, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2019-11-08 23:00:55 +08:00
|
|
|
|
2019-04-17 12:52:47 +08:00
|
|
|
define void @hoist_invariant_load(i1 %cond, i32* %np, i32 %M) {
|
|
|
|
; CHECK-LABEL: @hoist_invariant_load(
|
|
|
|
; CHECK-NEXT: entry:
|
|
|
|
; CHECK-NEXT: [[N:%.*]] = load i32, i32* [[NP:%.*]]
|
2019-11-08 23:00:55 +08:00
|
|
|
; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
|
2019-04-17 12:52:47 +08:00
|
|
|
; CHECK-NEXT: br label [[LOOP:%.*]]
|
|
|
|
; CHECK: loop:
|
|
|
|
; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[GUARDED:%.*]] ]
|
|
|
|
; CHECK-NEXT: [[GUARD_COND:%.*]] = icmp slt i32 [[IV]], [[N]]
|
|
|
|
; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[GUARD_COND]], [[WIDENABLE_COND]]
|
|
|
|
; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
|
|
|
|
; CHECK: deopt:
|
|
|
|
; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid() [ "deopt"() ]
|
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
; CHECK: guarded:
|
|
|
|
; CHECK-NEXT: [[LOOP_COND:%.*]] = icmp slt i32 [[IV]], [[M:%.*]]
|
|
|
|
; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1
|
|
|
|
; CHECK-NEXT: br i1 [[LOOP_COND]], label [[LOOP]], label [[EXIT:%.*]]
|
|
|
|
; CHECK: exit:
|
|
|
|
; CHECK-NEXT: ret void
|
|
|
|
;
|
|
|
|
entry:
|
|
|
|
br label %loop
|
|
|
|
|
|
|
|
loop:
|
|
|
|
%iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
|
|
|
|
%N = load i32, i32* %np
|
|
|
|
%guard_cond = icmp slt i32 %iv, %N
|
|
|
|
call void(i1, ...) @llvm.experimental.guard(i1 %guard_cond) [ "deopt"() ]
|
|
|
|
%loop_cond = icmp slt i32 %iv, %M
|
|
|
|
%iv.next = add i32 %iv, 1
|
|
|
|
br i1 %loop_cond, label %loop, label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
ret void
|
|
|
|
}
|