Skip to content

ValueTracking: pre-commit udiv/urem recurrence tests #109198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions llvm/test/Analysis/ValueTracking/recurrence-knownbits.ll
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,75 @@ exit:
ret i64 %res
}

define i64 @test_udiv(i1 %c) {
; CHECK-LABEL: @test_udiv(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 9, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
; CHECK-NEXT: [[IV_NEXT]] = udiv i64 [[IV]], 3
; CHECK-NEXT: br i1 [[C:%.*]], label [[EXIT:%.*]], label [[LOOP]]
; CHECK: exit:
; CHECK-NEXT: [[RES:%.*]] = and i64 [[IV]], 16
; CHECK-NEXT: ret i64 [[RES]]
;
entry:
br label %loop
loop:
%iv = phi i64 [9, %entry], [%iv.next, %loop]
%iv.next = udiv i64 %iv, 3
br i1 %c, label %exit, label %loop
exit:
%res = and i64 %iv, 16
ret i64 %res
}

define i64 @test_udiv_neg(i1 %c) {
; CHECK-LABEL: @test_udiv_neg(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 2, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
; CHECK-NEXT: [[IV_NEXT]] = udiv i64 9, [[IV]]
; CHECK-NEXT: br i1 [[C:%.*]], label [[EXIT:%.*]], label [[LOOP]]
; CHECK: exit:
; CHECK-NEXT: [[RES:%.*]] = and i64 [[IV]], 4
; CHECK-NEXT: ret i64 [[RES]]
;
entry:
br label %loop
loop:
%iv = phi i64 [2, %entry], [%iv.next, %loop]
%iv.next = udiv i64 9, %iv
br i1 %c, label %exit, label %loop
exit:
%res = and i64 %iv, 4
ret i64 %res
}

define i64 @test_urem(i1 %c) {
; CHECK-LABEL: @test_urem(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 3, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
; CHECK-NEXT: [[IV_NEXT]] = urem i64 9, [[IV]]
; CHECK-NEXT: br i1 [[C:%.*]], label [[EXIT:%.*]], label [[LOOP]]
; CHECK: exit:
; CHECK-NEXT: [[RES:%.*]] = and i64 [[IV]], 4
; CHECK-NEXT: ret i64 [[RES]]
;
entry:
br label %loop
loop:
%iv = phi i64 [3, %entry], [%iv.next, %loop]
%iv.next = urem i64 9, %iv
br i1 %c, label %exit, label %loop
exit:
%res = and i64 %iv, 4
ret i64 %res
}

define i64 @test_and(i1 %c) {
; CHECK-LABEL: @test_and(
; CHECK-NEXT: entry:
Expand Down
Loading