mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-26 23:21:11 +00:00
[TRE] Generate tests for accumulator recursion
This commit is contained in:
parent
21a9c7e6e7
commit
4042fb8ce4
@ -1,59 +1,95 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
|
||||
; RUN: opt < %s -passes=tailcallelim -verify-dom-info -S | FileCheck %s
|
||||
|
||||
define i32 @test1_factorial(i32 %x) {
|
||||
; CHECK-LABEL: define i32 @test1_factorial(
|
||||
; CHECK-SAME: i32 [[X:%.*]]) {
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_TR:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[ACCUMULATE:%.*]], [[THEN:%.*]] ]
|
||||
; CHECK-NEXT: [[X_TR:%.*]] = phi i32 [ [[X]], [[ENTRY]] ], [ [[TMP_6:%.*]], [[THEN]] ]
|
||||
; CHECK-NEXT: [[TMP_1:%.*]] = icmp sgt i32 [[X_TR]], 0
|
||||
; CHECK-NEXT: br i1 [[TMP_1]], label [[THEN]], label [[ELSE:%.*]]
|
||||
; CHECK: then:
|
||||
; CHECK-NEXT: [[TMP_6]] = add i32 [[X_TR]], -1
|
||||
; CHECK-NEXT: [[ACCUMULATE]] = mul i32 [[ACCUMULATOR_TR]], [[X_TR]]
|
||||
; CHECK-NEXT: br label [[TAILRECURSE]]
|
||||
; CHECK: else:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_RET_TR:%.*]] = mul i32 [[ACCUMULATOR_TR]], 1
|
||||
; CHECK-NEXT: ret i32 [[ACCUMULATOR_RET_TR]]
|
||||
;
|
||||
entry:
|
||||
%tmp.1 = icmp sgt i32 %x, 0
|
||||
br i1 %tmp.1, label %then, label %else
|
||||
%tmp.1 = icmp sgt i32 %x, 0
|
||||
br i1 %tmp.1, label %then, label %else
|
||||
then:
|
||||
%tmp.6 = add i32 %x, -1
|
||||
%recurse = call i32 @test1_factorial( i32 %tmp.6 )
|
||||
%accumulate = mul i32 %recurse, %x
|
||||
ret i32 %accumulate
|
||||
%tmp.6 = add i32 %x, -1
|
||||
%recurse = call i32 @test1_factorial( i32 %tmp.6 )
|
||||
%accumulate = mul i32 %recurse, %x
|
||||
ret i32 %accumulate
|
||||
else:
|
||||
ret i32 1
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define i32 @test1_factorial(
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK: %accumulator.tr = phi i32 [ 1, %entry ], [ %accumulate, %then ]
|
||||
; CHECK: then:
|
||||
; CHECK-NOT: %recurse
|
||||
; CHECK: %accumulate = mul i32 %accumulator.tr, %x.tr
|
||||
; CHECK: else:
|
||||
; CHECK: %accumulator.ret.tr = mul i32 %accumulator.tr, 1
|
||||
; CHECK: ret i32 %accumulator.ret.tr
|
||||
|
||||
; This is a more aggressive form of accumulator recursion insertion, which
|
||||
; This is a more aggressive form of accumulator recursion insertion, which
|
||||
; requires noticing that X doesn't change as we perform the tailcall.
|
||||
|
||||
define i32 @test2_mul(i32 %x, i32 %y) {
|
||||
; CHECK-LABEL: define i32 @test2_mul(
|
||||
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_TR:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ACCUMULATE:%.*]], [[ENDIF:%.*]] ]
|
||||
; CHECK-NEXT: [[Y_TR:%.*]] = phi i32 [ [[Y]], [[ENTRY]] ], [ [[TMP_8:%.*]], [[ENDIF]] ]
|
||||
; CHECK-NEXT: [[TMP_1:%.*]] = icmp eq i32 [[Y_TR]], 0
|
||||
; CHECK-NEXT: br i1 [[TMP_1]], label [[RETURN:%.*]], label [[ENDIF]]
|
||||
; CHECK: endif:
|
||||
; CHECK-NEXT: [[TMP_8]] = add i32 [[Y_TR]], -1
|
||||
; CHECK-NEXT: [[ACCUMULATE]] = add i32 [[ACCUMULATOR_TR]], [[X]]
|
||||
; CHECK-NEXT: br label [[TAILRECURSE]]
|
||||
; CHECK: return:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_RET_TR:%.*]] = add i32 [[ACCUMULATOR_TR]], [[X]]
|
||||
; CHECK-NEXT: ret i32 [[ACCUMULATOR_RET_TR]]
|
||||
;
|
||||
entry:
|
||||
%tmp.1 = icmp eq i32 %y, 0
|
||||
br i1 %tmp.1, label %return, label %endif
|
||||
%tmp.1 = icmp eq i32 %y, 0
|
||||
br i1 %tmp.1, label %return, label %endif
|
||||
endif:
|
||||
%tmp.8 = add i32 %y, -1
|
||||
%recurse = call i32 @test2_mul( i32 %x, i32 %tmp.8 )
|
||||
%accumulate = add i32 %recurse, %x
|
||||
ret i32 %accumulate
|
||||
%tmp.8 = add i32 %y, -1
|
||||
%recurse = call i32 @test2_mul( i32 %x, i32 %tmp.8 )
|
||||
%accumulate = add i32 %recurse, %x
|
||||
ret i32 %accumulate
|
||||
return:
|
||||
ret i32 %x
|
||||
ret i32 %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define i32 @test2_mul(
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK: %accumulator.tr = phi i32 [ 0, %entry ], [ %accumulate, %endif ]
|
||||
; CHECK: endif:
|
||||
; CHECK-NOT: %recurse
|
||||
; CHECK: %accumulate = add i32 %accumulator.tr, %x
|
||||
; CHECK: return:
|
||||
; CHECK: %accumulator.ret.tr = add i32 %accumulator.tr, %x
|
||||
; CHECK: ret i32 %accumulator.ret.tr
|
||||
|
||||
define i64 @test3_fib(i64 %n) nounwind readnone {
|
||||
; CHECK-LABEL: define i64 @test3_fib(
|
||||
; CHECK-SAME: i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_TR:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[ACCUMULATE:%.*]], [[BB1:%.*]] ]
|
||||
; CHECK-NEXT: [[N_TR:%.*]] = phi i64 [ [[N]], [[ENTRY]] ], [ [[TMP1:%.*]], [[BB1]] ]
|
||||
; CHECK-NEXT: switch i64 [[N_TR]], label [[BB1]] [
|
||||
; CHECK-NEXT: i64 0, label [[BB2:%.*]]
|
||||
; CHECK-NEXT: i64 1, label [[BB2]]
|
||||
; CHECK-NEXT: ]
|
||||
; CHECK: bb1:
|
||||
; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[N_TR]], -1
|
||||
; CHECK-NEXT: [[RECURSE1:%.*]] = tail call i64 @test3_fib(i64 [[TMP0]]) #[[ATTR1:[0-9]+]]
|
||||
; CHECK-NEXT: [[TMP1]] = add i64 [[N_TR]], -2
|
||||
; CHECK-NEXT: [[ACCUMULATE]] = add nsw i64 [[ACCUMULATOR_TR]], [[RECURSE1]]
|
||||
; CHECK-NEXT: br label [[TAILRECURSE]]
|
||||
; CHECK: bb2:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_RET_TR:%.*]] = add nsw i64 [[ACCUMULATOR_TR]], [[N_TR]]
|
||||
; CHECK-NEXT: ret i64 [[ACCUMULATOR_RET_TR]]
|
||||
;
|
||||
entry:
|
||||
switch i64 %n, label %bb1 [
|
||||
i64 0, label %bb2
|
||||
i64 1, label %bb2
|
||||
i64 0, label %bb2
|
||||
i64 1, label %bb2
|
||||
]
|
||||
|
||||
bb1:
|
||||
@ -68,23 +104,31 @@ bb2:
|
||||
ret i64 %n
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define i64 @test3_fib(
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK: %accumulator.tr = phi i64 [ 0, %entry ], [ %accumulate, %bb1 ]
|
||||
; CHECK: bb1:
|
||||
; CHECK-NOT: %recurse2
|
||||
; CHECK: %accumulate = add nsw i64 %accumulator.tr, %recurse1
|
||||
; CHECK: bb2:
|
||||
; CHECK: %accumulator.ret.tr = add nsw i64 %accumulator.tr, %n.tr
|
||||
; CHECK: ret i64 %accumulator.ret.tr
|
||||
|
||||
define i32 @test4_base_case_call() local_unnamed_addr {
|
||||
; CHECK-LABEL: define i32 @test4_base_case_call() local_unnamed_addr {
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_TR:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ACCUMULATE:%.*]], [[SW_DEFAULT:%.*]] ]
|
||||
; CHECK-NEXT: [[BASE:%.*]] = tail call i32 @test4_helper()
|
||||
; CHECK-NEXT: switch i32 [[BASE]], label [[SW_DEFAULT]] [
|
||||
; CHECK-NEXT: i32 1, label [[CLEANUP:%.*]]
|
||||
; CHECK-NEXT: i32 5, label [[CLEANUP]]
|
||||
; CHECK-NEXT: i32 7, label [[CLEANUP]]
|
||||
; CHECK-NEXT: ]
|
||||
; CHECK: sw.default:
|
||||
; CHECK-NEXT: [[ACCUMULATE]] = add nsw i32 [[ACCUMULATOR_TR]], 1
|
||||
; CHECK-NEXT: br label [[TAILRECURSE]]
|
||||
; CHECK: cleanup:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_RET_TR:%.*]] = add nsw i32 [[ACCUMULATOR_TR]], [[BASE]]
|
||||
; CHECK-NEXT: ret i32 [[ACCUMULATOR_RET_TR]]
|
||||
;
|
||||
entry:
|
||||
%base = call i32 @test4_helper()
|
||||
switch i32 %base, label %sw.default [
|
||||
i32 1, label %cleanup
|
||||
i32 5, label %cleanup
|
||||
i32 7, label %cleanup
|
||||
i32 1, label %cleanup
|
||||
i32 5, label %cleanup
|
||||
i32 7, label %cleanup
|
||||
]
|
||||
|
||||
sw.default:
|
||||
@ -99,17 +143,28 @@ cleanup:
|
||||
|
||||
declare i32 @test4_helper()
|
||||
|
||||
; CHECK-LABEL: define i32 @test4_base_case_call(
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK: %accumulator.tr = phi i32 [ 0, %entry ], [ %accumulate, %sw.default ]
|
||||
; CHECK: sw.default:
|
||||
; CHECK-NOT: %recurse
|
||||
; CHECK: %accumulate = add nsw i32 %accumulator.tr, 1
|
||||
; CHECK: cleanup:
|
||||
; CHECK: %accumulator.ret.tr = add nsw i32 %accumulator.tr, %base
|
||||
; CHECK: ret i32 %accumulator.ret.tr
|
||||
|
||||
define i32 @test5_base_case_load(ptr nocapture %A, i32 %n) local_unnamed_addr {
|
||||
; CHECK-LABEL: define i32 @test5_base_case_load(
|
||||
; CHECK-SAME: ptr nocapture [[A:%.*]], i32 [[N:%.*]]) local_unnamed_addr {
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_TR:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ACCUMULATE:%.*]], [[IF_END:%.*]] ]
|
||||
; CHECK-NEXT: [[N_TR:%.*]] = phi i32 [ [[N]], [[ENTRY]] ], [ [[SUB:%.*]], [[IF_END]] ]
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[N_TR]], 0
|
||||
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END]]
|
||||
; CHECK: if.then:
|
||||
; CHECK-NEXT: [[BASE:%.*]] = load i32, ptr [[A]], align 4
|
||||
; CHECK-NEXT: [[ACCUMULATOR_RET_TR:%.*]] = add i32 [[ACCUMULATOR_TR]], [[BASE]]
|
||||
; CHECK-NEXT: ret i32 [[ACCUMULATOR_RET_TR]]
|
||||
; CHECK: if.end:
|
||||
; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[N_TR]] to i64
|
||||
; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM]]
|
||||
; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[ARRAYIDX1]], align 4
|
||||
; CHECK-NEXT: [[SUB]] = add i32 [[N_TR]], -1
|
||||
; CHECK-NEXT: [[ACCUMULATE]] = add i32 [[ACCUMULATOR_TR]], [[LOAD]]
|
||||
; CHECK-NEXT: br label [[TAILRECURSE]]
|
||||
;
|
||||
entry:
|
||||
%cmp = icmp eq i32 %n, 0
|
||||
br i1 %cmp, label %if.then, label %if.end
|
||||
@ -128,21 +183,39 @@ if.end:
|
||||
ret i32 %accumulate
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define i32 @test5_base_case_load(
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK: %accumulator.tr = phi i32 [ 0, %entry ], [ %accumulate, %if.end ]
|
||||
; CHECK: if.then:
|
||||
; CHECK: %accumulator.ret.tr = add i32 %accumulator.tr, %base
|
||||
; CHECK: ret i32 %accumulator.ret.tr
|
||||
; CHECK: if.end:
|
||||
; CHECK-NOT: %recurse
|
||||
; CHECK: %accumulate = add i32 %accumulator.tr, %load
|
||||
|
||||
define i32 @test6_multiple_returns(i32 %x, i32 %y) local_unnamed_addr {
|
||||
; CHECK-LABEL: define i32 @test6_multiple_returns(
|
||||
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) local_unnamed_addr {
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_TR:%.*]] = phi i32 [ [[ACCUMULATOR_TR]], [[CASE99:%.*]] ], [ 0, [[ENTRY:%.*]] ], [ [[ACCUMULATE:%.*]], [[DEFAULT:%.*]] ]
|
||||
; CHECK-NEXT: [[X_TR:%.*]] = phi i32 [ [[X]], [[ENTRY]] ], [ [[SUB1:%.*]], [[CASE99]] ], [ [[SUB2:%.*]], [[DEFAULT]] ]
|
||||
; CHECK-NEXT: [[RET_TR:%.*]] = phi i32 [ poison, [[ENTRY]] ], [ [[CURRENT_RET_TR:%.*]], [[CASE99]] ], [ [[RET_TR]], [[DEFAULT]] ]
|
||||
; CHECK-NEXT: [[RET_KNOWN_TR:%.*]] = phi i1 [ false, [[ENTRY]] ], [ true, [[CASE99]] ], [ [[RET_KNOWN_TR]], [[DEFAULT]] ]
|
||||
; CHECK-NEXT: switch i32 [[X_TR]], label [[DEFAULT]] [
|
||||
; CHECK-NEXT: i32 0, label [[CASE0:%.*]]
|
||||
; CHECK-NEXT: i32 99, label [[CASE99]]
|
||||
; CHECK-NEXT: ]
|
||||
; CHECK: case0:
|
||||
; CHECK-NEXT: [[HELPER:%.*]] = tail call i32 @test6_helper()
|
||||
; CHECK-NEXT: [[ACCUMULATOR_RET_TR2:%.*]] = add i32 [[ACCUMULATOR_TR]], [[HELPER]]
|
||||
; CHECK-NEXT: [[CURRENT_RET_TR1:%.*]] = select i1 [[RET_KNOWN_TR]], i32 [[RET_TR]], i32 [[ACCUMULATOR_RET_TR2]]
|
||||
; CHECK-NEXT: ret i32 [[CURRENT_RET_TR1]]
|
||||
; CHECK: case99:
|
||||
; CHECK-NEXT: [[SUB1]] = add i32 [[X_TR]], -1
|
||||
; CHECK-NEXT: [[ACCUMULATOR_RET_TR:%.*]] = add i32 [[ACCUMULATOR_TR]], 18
|
||||
; CHECK-NEXT: [[CURRENT_RET_TR]] = select i1 [[RET_KNOWN_TR]], i32 [[RET_TR]], i32 [[ACCUMULATOR_RET_TR]]
|
||||
; CHECK-NEXT: br label [[TAILRECURSE]]
|
||||
; CHECK: default:
|
||||
; CHECK-NEXT: [[SUB2]] = add i32 [[X_TR]], -1
|
||||
; CHECK-NEXT: [[ACCUMULATE]] = add i32 [[ACCUMULATOR_TR]], [[Y]]
|
||||
; CHECK-NEXT: br label [[TAILRECURSE]]
|
||||
;
|
||||
entry:
|
||||
switch i32 %x, label %default [
|
||||
i32 0, label %case0
|
||||
i32 99, label %case99
|
||||
i32 0, label %case0
|
||||
i32 99, label %case99
|
||||
]
|
||||
|
||||
case0:
|
||||
@ -163,26 +236,36 @@ default:
|
||||
|
||||
declare i32 @test6_helper()
|
||||
|
||||
; CHECK-LABEL: define i32 @test6_multiple_returns(
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK: %accumulator.tr = phi i32 [ %accumulator.tr, %case99 ], [ 0, %entry ], [ %accumulate, %default ]
|
||||
; CHECK: %ret.tr = phi i32 [ poison, %entry ], [ %current.ret.tr, %case99 ], [ %ret.tr, %default ]
|
||||
; CHECK: %ret.known.tr = phi i1 [ false, %entry ], [ true, %case99 ], [ %ret.known.tr, %default ]
|
||||
; CHECK: case0:
|
||||
; CHECK: %accumulator.ret.tr2 = add i32 %accumulator.tr, %helper
|
||||
; CHECK: %current.ret.tr1 = select i1 %ret.known.tr, i32 %ret.tr, i32 %accumulator.ret.tr2
|
||||
; CHECK: case99:
|
||||
; CHECK-NOT: %recurse
|
||||
; CHECK: %accumulator.ret.tr = add i32 %accumulator.tr, 18
|
||||
; CHECK: %current.ret.tr = select i1 %ret.known.tr, i32 %ret.tr, i32 %accumulator.ret.tr
|
||||
; CHECK: default:
|
||||
; CHECK-NOT: %recurse
|
||||
; CHECK: %accumulate = add i32 %accumulator.tr, %y
|
||||
|
||||
; It is only safe to transform one accumulator per function, make sure we don't
|
||||
; try to remove more.
|
||||
|
||||
define i32 @test7_multiple_accumulators(i32 %a) local_unnamed_addr {
|
||||
; CHECK-LABEL: define i32 @test7_multiple_accumulators(
|
||||
; CHECK-SAME: i32 [[A:%.*]]) local_unnamed_addr {
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_TR:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ACCUMULATE1:%.*]], [[IF_THEN2:%.*]] ]
|
||||
; CHECK-NEXT: [[A_TR:%.*]] = phi i32 [ [[A]], [[ENTRY]] ], [ [[SUB:%.*]], [[IF_THEN2]] ]
|
||||
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[A_TR]], 0
|
||||
; CHECK-NEXT: br i1 [[TOBOOL]], label [[RETURN:%.*]], label [[IF_END:%.*]]
|
||||
; CHECK: if.end:
|
||||
; CHECK-NEXT: [[AND:%.*]] = and i32 [[A_TR]], 1
|
||||
; CHECK-NEXT: [[TOBOOL1:%.*]] = icmp eq i32 [[AND]], 0
|
||||
; CHECK-NEXT: [[SUB]] = add nsw i32 [[A_TR]], -1
|
||||
; CHECK-NEXT: br i1 [[TOBOOL1]], label [[IF_END3:%.*]], label [[IF_THEN2]]
|
||||
; CHECK: if.then2:
|
||||
; CHECK-NEXT: [[ACCUMULATE1]] = add nsw i32 [[ACCUMULATOR_TR]], 1
|
||||
; CHECK-NEXT: br label [[TAILRECURSE]]
|
||||
; CHECK: if.end3:
|
||||
; CHECK-NEXT: [[RECURSE2:%.*]] = tail call i32 @test7_multiple_accumulators(i32 [[SUB]])
|
||||
; CHECK-NEXT: [[ACCUMULATE2:%.*]] = mul nsw i32 [[RECURSE2]], 2
|
||||
; CHECK-NEXT: [[ACCUMULATOR_RET_TR:%.*]] = add nsw i32 [[ACCUMULATOR_TR]], [[ACCUMULATE2]]
|
||||
; CHECK-NEXT: ret i32 [[ACCUMULATOR_RET_TR]]
|
||||
; CHECK: return:
|
||||
; CHECK-NEXT: [[ACCUMULATOR_RET_TR1:%.*]] = add nsw i32 [[ACCUMULATOR_TR]], 0
|
||||
; CHECK-NEXT: ret i32 [[ACCUMULATOR_RET_TR1]]
|
||||
;
|
||||
entry:
|
||||
%tobool = icmp eq i32 %a, 0
|
||||
br i1 %tobool, label %return, label %if.end
|
||||
@ -207,17 +290,3 @@ return:
|
||||
%retval.0 = phi i32 [ %accumulate1, %if.then2 ], [ %accumulate2, %if.end3 ], [ 0, %entry ]
|
||||
ret i32 %retval.0
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define i32 @test7_multiple_accumulators(
|
||||
; CHECK: tailrecurse:
|
||||
; CHECK: %accumulator.tr = phi i32 [ 0, %entry ], [ %accumulate1, %if.then2 ]
|
||||
; CHECK: if.then2:
|
||||
; CHECK-NOT: %recurse1
|
||||
; CHECK: %accumulate1 = add nsw i32 %accumulator.tr, 1
|
||||
; CHECK: if.end3:
|
||||
; CHECK: %recurse2
|
||||
; CHECK: %accumulator.ret.tr = add nsw i32 %accumulator.tr, %accumulate2
|
||||
; CHECK: ret i32 %accumulator.ret.tr
|
||||
; CHECK: return:
|
||||
; CHECK: %accumulator.ret.tr1 = add nsw i32 %accumulator.tr, 0
|
||||
; CHECK: ret i32 %accumulator.ret.tr1
|
||||
|
Loading…
Reference in New Issue
Block a user