[llvm] ba29549 - [InstSimplify] add tests for FP rounding intrinsics; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 31 07:00:39 PDT 2022
Author: Sanjay Patel
Date: 2022-07-31T10:00:27-04:00
New Revision: ba295492318f10eb9b28e8583cdb39386779517c
URL: https://github.com/llvm/llvm-project/commit/ba295492318f10eb9b28e8583cdb39386779517c
DIFF: https://github.com/llvm/llvm-project/commit/ba295492318f10eb9b28e8583cdb39386779517c.diff
LOG: [InstSimplify] add tests for FP rounding intrinsics; NFC
See issue #56775
Added:
Modified:
llvm/test/Transforms/InstSimplify/round-intrinsics.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/round-intrinsics.ll b/llvm/test/Transforms/InstSimplify/round-intrinsics.ll
index b4c0804a5eee0..fc8d1e64c5326 100644
--- a/llvm/test/Transforms/InstSimplify/round-intrinsics.ll
+++ b/llvm/test/Transforms/InstSimplify/round-intrinsics.ll
@@ -131,6 +131,468 @@ define float @uitofp_rint(i32 %arg) {
ret float %rint
}
+define float @floor_trunc(float %x) {
+; CHECK-LABEL: @floor_trunc(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.trunc.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.floor.f32(float %x)
+ %r = call float @llvm.trunc.f32(float %a)
+ ret float %r
+}
+
+define float @floor_ceil(float %x) {
+; CHECK-LABEL: @floor_ceil(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.ceil.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.floor.f32(float %x)
+ %r = call float @llvm.ceil.f32(float %a)
+ ret float %r
+}
+
+define float @floor_round(float %x) {
+; CHECK-LABEL: @floor_round(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.round.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.floor.f32(float %x)
+ %r = call float @llvm.round.f32(float %a)
+ ret float %r
+}
+
+define float @floor_roundeven(float %x) {
+; CHECK-LABEL: @floor_roundeven(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.roundeven.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.floor.f32(float %x)
+ %r = call float @llvm.roundeven.f32(float %a)
+ ret float %r
+}
+
+define float @floor_nearbyint(float %x) {
+; CHECK-LABEL: @floor_nearbyint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.nearbyint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.floor.f32(float %x)
+ %r = call float @llvm.nearbyint.f32(float %a)
+ ret float %r
+}
+
+define float @floor_rint(float %x) {
+; CHECK-LABEL: @floor_rint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.floor.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.rint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.floor.f32(float %x)
+ %r = call float @llvm.rint.f32(float %a)
+ ret float %r
+}
+
+define float @trunc_floor(float %x) {
+; CHECK-LABEL: @trunc_floor(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.floor.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.trunc.f32(float %x)
+ %r = call float @llvm.floor.f32(float %a)
+ ret float %r
+}
+
+define float @trunc_ceil(float %x) {
+; CHECK-LABEL: @trunc_ceil(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.ceil.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.trunc.f32(float %x)
+ %r = call float @llvm.ceil.f32(float %a)
+ ret float %r
+}
+
+define float @trunc_round(float %x) {
+; CHECK-LABEL: @trunc_round(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.round.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.trunc.f32(float %x)
+ %r = call float @llvm.round.f32(float %a)
+ ret float %r
+}
+
+define float @trunc_roundeven(float %x) {
+; CHECK-LABEL: @trunc_roundeven(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.roundeven.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.trunc.f32(float %x)
+ %r = call float @llvm.roundeven.f32(float %a)
+ ret float %r
+}
+
+define float @trunc_nearbyint(float %x) {
+; CHECK-LABEL: @trunc_nearbyint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.nearbyint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.trunc.f32(float %x)
+ %r = call float @llvm.nearbyint.f32(float %a)
+ ret float %r
+}
+
+define float @trunc_rint(float %x) {
+; CHECK-LABEL: @trunc_rint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.trunc.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.rint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.trunc.f32(float %x)
+ %r = call float @llvm.rint.f32(float %a)
+ ret float %r
+}
+
+define float @ceil_floor(float %x) {
+; CHECK-LABEL: @ceil_floor(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.floor.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.ceil.f32(float %x)
+ %r = call float @llvm.floor.f32(float %a)
+ ret float %r
+}
+
+define float @ceil_trunc(float %x) {
+; CHECK-LABEL: @ceil_trunc(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.trunc.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.ceil.f32(float %x)
+ %r = call float @llvm.trunc.f32(float %a)
+ ret float %r
+}
+
+define float @ceil_round(float %x) {
+; CHECK-LABEL: @ceil_round(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.round.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.ceil.f32(float %x)
+ %r = call float @llvm.round.f32(float %a)
+ ret float %r
+}
+
+define float @ceil_roundeven(float %x) {
+; CHECK-LABEL: @ceil_roundeven(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.roundeven.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.ceil.f32(float %x)
+ %r = call float @llvm.roundeven.f32(float %a)
+ ret float %r
+}
+
+define float @ceil_nearbyint(float %x) {
+; CHECK-LABEL: @ceil_nearbyint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.nearbyint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.ceil.f32(float %x)
+ %r = call float @llvm.nearbyint.f32(float %a)
+ ret float %r
+}
+
+define float @ceil_rint(float %x) {
+; CHECK-LABEL: @ceil_rint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.ceil.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.rint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.ceil.f32(float %x)
+ %r = call float @llvm.rint.f32(float %a)
+ ret float %r
+}
+
+define float @round_floor(float %x) {
+; CHECK-LABEL: @round_floor(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.floor.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.round.f32(float %x)
+ %r = call float @llvm.floor.f32(float %a)
+ ret float %r
+}
+
+define float @round_trunc(float %x) {
+; CHECK-LABEL: @round_trunc(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.trunc.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.round.f32(float %x)
+ %r = call float @llvm.trunc.f32(float %a)
+ ret float %r
+}
+
+define float @round_ceil(float %x) {
+; CHECK-LABEL: @round_ceil(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.ceil.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.round.f32(float %x)
+ %r = call float @llvm.ceil.f32(float %a)
+ ret float %r
+}
+
+define float @round_roundeven(float %x) {
+; CHECK-LABEL: @round_roundeven(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.roundeven.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.round.f32(float %x)
+ %r = call float @llvm.roundeven.f32(float %a)
+ ret float %r
+}
+
+define float @round_nearbyint(float %x) {
+; CHECK-LABEL: @round_nearbyint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.nearbyint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.round.f32(float %x)
+ %r = call float @llvm.nearbyint.f32(float %a)
+ ret float %r
+}
+
+define float @round_rint(float %x) {
+; CHECK-LABEL: @round_rint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.round.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.rint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.round.f32(float %x)
+ %r = call float @llvm.rint.f32(float %a)
+ ret float %r
+}
+
+define float @roundeven_floor(float %x) {
+; CHECK-LABEL: @roundeven_floor(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.floor.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.roundeven.f32(float %x)
+ %r = call float @llvm.floor.f32(float %a)
+ ret float %r
+}
+
+define float @roundeven_trunc(float %x) {
+; CHECK-LABEL: @roundeven_trunc(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.trunc.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.roundeven.f32(float %x)
+ %r = call float @llvm.trunc.f32(float %a)
+ ret float %r
+}
+
+define float @roundeven_ceil(float %x) {
+; CHECK-LABEL: @roundeven_ceil(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.ceil.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.roundeven.f32(float %x)
+ %r = call float @llvm.ceil.f32(float %a)
+ ret float %r
+}
+
+define float @roundeven_round(float %x) {
+; CHECK-LABEL: @roundeven_round(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.round.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.roundeven.f32(float %x)
+ %r = call float @llvm.round.f32(float %a)
+ ret float %r
+}
+
+define float @roundeven_nearbyint(float %x) {
+; CHECK-LABEL: @roundeven_nearbyint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.nearbyint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.roundeven.f32(float %x)
+ %r = call float @llvm.nearbyint.f32(float %a)
+ ret float %r
+}
+
+define float @roundeven_rint(float %x) {
+; CHECK-LABEL: @roundeven_rint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.roundeven.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.rint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.roundeven.f32(float %x)
+ %r = call float @llvm.rint.f32(float %a)
+ ret float %r
+}
+
+define float @nearbyint_floor(float %x) {
+; CHECK-LABEL: @nearbyint_floor(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.floor.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.nearbyint.f32(float %x)
+ %r = call float @llvm.floor.f32(float %a)
+ ret float %r
+}
+
+define float @nearbyint_trunc(float %x) {
+; CHECK-LABEL: @nearbyint_trunc(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.trunc.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.nearbyint.f32(float %x)
+ %r = call float @llvm.trunc.f32(float %a)
+ ret float %r
+}
+
+define float @nearbyint_ceil(float %x) {
+; CHECK-LABEL: @nearbyint_ceil(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.ceil.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.nearbyint.f32(float %x)
+ %r = call float @llvm.ceil.f32(float %a)
+ ret float %r
+}
+
+define float @nearbyint_round(float %x) {
+; CHECK-LABEL: @nearbyint_round(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.round.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.nearbyint.f32(float %x)
+ %r = call float @llvm.round.f32(float %a)
+ ret float %r
+}
+
+define float @nearbyint_roundeven(float %x) {
+; CHECK-LABEL: @nearbyint_roundeven(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.roundeven.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.nearbyint.f32(float %x)
+ %r = call float @llvm.roundeven.f32(float %a)
+ ret float %r
+}
+
+define float @nearbyint_rint(float %x) {
+; CHECK-LABEL: @nearbyint_rint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.nearbyint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.rint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.nearbyint.f32(float %x)
+ %r = call float @llvm.rint.f32(float %a)
+ ret float %r
+}
+
+define float @rint_floor(float %x) {
+; CHECK-LABEL: @rint_floor(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.floor.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.rint.f32(float %x)
+ %r = call float @llvm.floor.f32(float %a)
+ ret float %r
+}
+
+define float @rint_trunc(float %x) {
+; CHECK-LABEL: @rint_trunc(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.trunc.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.rint.f32(float %x)
+ %r = call float @llvm.trunc.f32(float %a)
+ ret float %r
+}
+
+define float @rint_ceil(float %x) {
+; CHECK-LABEL: @rint_ceil(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.ceil.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.rint.f32(float %x)
+ %r = call float @llvm.ceil.f32(float %a)
+ ret float %r
+}
+
+define float @rint_round(float %x) {
+; CHECK-LABEL: @rint_round(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.round.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.rint.f32(float %x)
+ %r = call float @llvm.round.f32(float %a)
+ ret float %r
+}
+
+define float @rint_roundeven(float %x) {
+; CHECK-LABEL: @rint_roundeven(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.roundeven.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.rint.f32(float %x)
+ %r = call float @llvm.roundeven.f32(float %a)
+ ret float %r
+}
+
+define float @rint_nearbyint(float %x) {
+; CHECK-LABEL: @rint_nearbyint(
+; CHECK-NEXT: [[A:%.*]] = call float @llvm.rint.f32(float [[X:%.*]])
+; CHECK-NEXT: [[R:%.*]] = call float @llvm.nearbyint.f32(float [[A]])
+; CHECK-NEXT: ret float [[R]]
+;
+ %a = call float @llvm.rint.f32(float %x)
+ %r = call float @llvm.nearbyint.f32(float %a)
+ ret float %r
+}
+
declare float @llvm.floor.f32(float) #0
declare float @llvm.trunc.f32(float) #0
declare float @llvm.ceil.f32(float) #0
More information about the llvm-commits
mailing list