Skip to content

Commit 562ce8b

Browse files
authored
LoopVectorize: add negative test for lrint, llrint (#70211)
With the recent change 98c90a1 (ISel: introduce vector ISD::LRINT, ISD::LLRINT; custom RISCV lowering), it is now possible to vectorize llvm.lrint and llvm.llrint with a trivial change to VectorUtils. In preparation for this change, and the corresponding test update, add a negative test for lrint and llrint.
1 parent 8ea260a commit 562ce8b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

llvm/test/Transforms/LoopVectorize/intrinsic.ll

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,3 +1597,55 @@ for.body: ; preds = %entry, %for.body
15971597
for.end: ; preds = %for.body, %entry
15981598
ret void
15991599
}
1600+
1601+
declare i32 @llvm.lrint.i32.f32(float)
1602+
1603+
define void @lrint_i32_f32(ptr %x, ptr %y, i64 %n) {
1604+
; CHECK-LABEL: @lrint_i32_f32(
1605+
; CHECK-NOT: llvm.lrint.v4i32.v4f32
1606+
; CHECK: ret void
1607+
;
1608+
entry:
1609+
%cmp = icmp sgt i64 %n, 0
1610+
br i1 %cmp, label %for.body, label %exit
1611+
1612+
for.body: ; preds = %entry, %for.body
1613+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
1614+
%gep.load = getelementptr inbounds float, ptr %x, i64 %iv
1615+
%0 = load float, ptr %gep.load, align 4
1616+
%1 = tail call i32 @llvm.lrint.i32.f32(float %0)
1617+
%gep.store = getelementptr inbounds i32, ptr %y, i64 %iv
1618+
store i32 %1, ptr %gep.store, align 4
1619+
%iv.next = add nuw nsw i64 %iv, 1
1620+
%exitcond = icmp eq i64 %iv.next, %n
1621+
br i1 %exitcond, label %exit, label %for.body
1622+
1623+
exit: ; preds = %for.body, %entry
1624+
ret void
1625+
}
1626+
1627+
declare i64 @llvm.llrint.i64.f32(float)
1628+
1629+
define void @llrint_i64_f32(ptr %x, ptr %y, i64 %n) {
1630+
; CHECK-LABEL: @llrint_i64_f32(
1631+
; CHECK-NOT: llvm.llrint.v4i32.v4f32
1632+
; CHECK: ret void
1633+
;
1634+
entry:
1635+
%cmp = icmp sgt i64 %n, 0
1636+
br i1 %cmp, label %for.body, label %exit
1637+
1638+
for.body: ; preds = %entry, %for.body
1639+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
1640+
%gep.load = getelementptr inbounds float, ptr %x, i64 %iv
1641+
%0 = load float, ptr %gep.load, align 4
1642+
%1 = tail call i64 @llvm.llrint.i64.f32(float %0)
1643+
%gep.store = getelementptr inbounds i64, ptr %y, i64 %iv
1644+
store i64 %1, ptr %gep.store, align 4
1645+
%iv.next = add nuw nsw i64 %iv, 1
1646+
%exitcond = icmp eq i64 %iv.next, %n
1647+
br i1 %exitcond, label %exit, label %for.body
1648+
1649+
exit: ; preds = %for.body, %entry
1650+
ret void
1651+
}

0 commit comments

Comments
 (0)