Skip to content

LoopVectorize: add negative test for lrint, llrint #70211

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
Oct 31, 2023
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
52 changes: 52 additions & 0 deletions llvm/test/Transforms/LoopVectorize/intrinsic.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1597,3 +1597,55 @@ for.body: ; preds = %entry, %for.body
for.end: ; preds = %for.body, %entry
ret void
}

declare i32 @llvm.lrint.i32.f32(float)

define void @lrint_i32_f32(ptr %x, ptr %y, i64 %n) {
; CHECK-LABEL: @lrint_i32_f32(
; CHECK-NOT: llvm.lrint.v4i32.v4f32
; CHECK: ret void
;
entry:
%cmp = icmp sgt i64 %n, 0
br i1 %cmp, label %for.body, label %exit

for.body: ; preds = %entry, %for.body
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
%gep.load = getelementptr inbounds float, ptr %x, i64 %iv
%0 = load float, ptr %gep.load, align 4
%1 = tail call i32 @llvm.lrint.i32.f32(float %0)
%gep.store = getelementptr inbounds i32, ptr %y, i64 %iv
store i32 %1, ptr %gep.store, align 4
%iv.next = add nuw nsw i64 %iv, 1
%exitcond = icmp eq i64 %iv.next, %n
br i1 %exitcond, label %exit, label %for.body

exit: ; preds = %for.body, %entry
ret void
}

declare i64 @llvm.llrint.i64.f32(float)

define void @llrint_i64_f32(ptr %x, ptr %y, i64 %n) {
; CHECK-LABEL: @llrint_i64_f32(
; CHECK-NOT: llvm.llrint.v4i32.v4f32
; CHECK: ret void
;
entry:
%cmp = icmp sgt i64 %n, 0
br i1 %cmp, label %for.body, label %exit

for.body: ; preds = %entry, %for.body
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
%gep.load = getelementptr inbounds float, ptr %x, i64 %iv
%0 = load float, ptr %gep.load, align 4
%1 = tail call i64 @llvm.llrint.i64.f32(float %0)
%gep.store = getelementptr inbounds i64, ptr %y, i64 %iv
store i64 %1, ptr %gep.store, align 4
%iv.next = add nuw nsw i64 %iv, 1
%exitcond = icmp eq i64 %iv.next, %n
br i1 %exitcond, label %exit, label %for.body

exit: ; preds = %for.body, %entry
ret void
}