[llvm] 4013cfd - [GVN] add tests for >2 arg commutable intrinsics; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 3 07:15:08 PDT 2020
Author: Sanjay Patel
Date: 2020-09-03T10:14:52-04:00
New Revision: 4013cfd34df363dfd8d963375d72349c5da2623c
URL: https://github.com/llvm/llvm-project/commit/4013cfd34df363dfd8d963375d72349c5da2623c
DIFF: https://github.com/llvm/llvm-project/commit/4013cfd34df363dfd8d963375d72349c5da2623c.diff
LOG: [GVN] add tests for >2 arg commutable intrinsics; NFC
Added:
Modified:
llvm/test/Transforms/GVN/commute.ll
llvm/test/Transforms/NewGVN/commute.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/GVN/commute.ll b/llvm/test/Transforms/GVN/commute.ll
index 72506c0ece28..d0f26f6e27e6 100644
--- a/llvm/test/Transforms/GVN/commute.ll
+++ b/llvm/test/Transforms/GVN/commute.ll
@@ -67,3 +67,47 @@ if.end:
%umul = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %x, i32 %y)
ret { i32, i1 } %umul
}
+
+declare i16 @llvm.smul.fix.i16(i16, i16, i32)
+declare i16 @llvm.umul.fix.i16(i16, i16, i32)
+
+define i16 @intrinsic_3_args(i16 %x, i16 %y) {
+; CHECK-LABEL: @intrinsic_3_args(
+; CHECK-NEXT: [[M1:%.*]] = call i16 @llvm.smul.fix.i16(i16 [[X:%.*]], i16 [[Y:%.*]], i32 1)
+; CHECK-NEXT: [[M2:%.*]] = call i16 @llvm.smul.fix.i16(i16 [[Y]], i16 [[X]], i32 1)
+; CHECK-NEXT: [[R:%.*]] = sub i16 [[M1]], [[M2]]
+; CHECK-NEXT: ret i16 [[R]]
+;
+ %m1 = call i16 @llvm.smul.fix.i16(i16 %x, i16 %y, i32 1)
+ %m2 = call i16 @llvm.smul.fix.i16(i16 %y, i16 %x, i32 1)
+ %r = sub i16 %m1, %m2
+ ret i16 %r
+}
+
+define i16 @intrinsic_3_args_not_same(i16 %x, i16 %y) {
+; CHECK-LABEL: @intrinsic_3_args_not_same(
+; CHECK-NEXT: [[M1:%.*]] = call i16 @llvm.umul.fix.i16(i16 [[X:%.*]], i16 [[Y:%.*]], i32 2)
+; CHECK-NEXT: [[M2:%.*]] = call i16 @llvm.umul.fix.i16(i16 [[Y]], i16 [[X]], i32 1)
+; CHECK-NEXT: [[R:%.*]] = sub i16 [[M1]], [[M2]]
+; CHECK-NEXT: ret i16 [[R]]
+;
+ %m1 = call i16 @llvm.umul.fix.i16(i16 %x, i16 %y, i32 2)
+ %m2 = call i16 @llvm.umul.fix.i16(i16 %y, i16 %x, i32 1)
+ %r = sub i16 %m1, %m2
+ ret i16 %r
+}
+
+declare float @llvm.fma.f32(float, float, float)
+
+define float @fma(float %x, float %y) {
+; CHECK-LABEL: @fma(
+; CHECK-NEXT: [[M1:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float 1.000000e+00)
+; CHECK-NEXT: [[M2:%.*]] = call float @llvm.fma.f32(float [[Y]], float [[X]], float 1.000000e+00)
+; CHECK-NEXT: [[R:%.*]] = fdiv nnan float [[M1]], [[M2]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %m1 = call float @llvm.fma.f32(float %x, float %y, float 1.0)
+ %m2 = call float @llvm.fma.f32(float %y, float %x, float 1.0)
+ %r = fdiv nnan float %m1, %m2
+ ret float %r
+}
diff --git a/llvm/test/Transforms/NewGVN/commute.ll b/llvm/test/Transforms/NewGVN/commute.ll
index d7737dd04f97..f4b53621e420 100644
--- a/llvm/test/Transforms/NewGVN/commute.ll
+++ b/llvm/test/Transforms/NewGVN/commute.ll
@@ -29,6 +29,8 @@ define void @cmp(i32 %x, i32 %y) {
ret void
}
+declare i32 @llvm.smax.i32(i32, i32)
+
define void @intrinsic(i32 %x, i32 %y) {
; CHECK-LABEL: @intrinsic(
; CHECK-NEXT: [[M1:%.*]] = call i32 @llvm.smax.i32(i32 [[X:%.*]], i32 [[Y:%.*]])
@@ -42,4 +44,46 @@ define void @intrinsic(i32 %x, i32 %y) {
ret void
}
-declare i32 @llvm.smax.i32(i32, i32)
+declare i16 @llvm.smul.fix.i16(i16, i16, i32)
+declare i16 @llvm.umul.fix.i16(i16, i16, i32)
+
+define i16 @intrinsic_3_args(i16 %x, i16 %y) {
+; CHECK-LABEL: @intrinsic_3_args(
+; CHECK-NEXT: [[M1:%.*]] = call i16 @llvm.smul.fix.i16(i16 [[X:%.*]], i16 [[Y:%.*]], i32 1)
+; CHECK-NEXT: [[M2:%.*]] = call i16 @llvm.smul.fix.i16(i16 [[Y]], i16 [[X]], i32 1)
+; CHECK-NEXT: [[R:%.*]] = sub i16 [[M1]], [[M2]]
+; CHECK-NEXT: ret i16 [[R]]
+;
+ %m1 = call i16 @llvm.smul.fix.i16(i16 %x, i16 %y, i32 1)
+ %m2 = call i16 @llvm.smul.fix.i16(i16 %y, i16 %x, i32 1)
+ %r = sub i16 %m1, %m2
+ ret i16 %r
+}
+
+define i16 @intrinsic_3_args_not_same(i16 %x, i16 %y) {
+; CHECK-LABEL: @intrinsic_3_args_not_same(
+; CHECK-NEXT: [[M1:%.*]] = call i16 @llvm.umul.fix.i16(i16 [[X:%.*]], i16 [[Y:%.*]], i32 2)
+; CHECK-NEXT: [[M2:%.*]] = call i16 @llvm.umul.fix.i16(i16 [[Y]], i16 [[X]], i32 1)
+; CHECK-NEXT: [[R:%.*]] = sub i16 [[M1]], [[M2]]
+; CHECK-NEXT: ret i16 [[R]]
+;
+ %m1 = call i16 @llvm.umul.fix.i16(i16 %x, i16 %y, i32 2)
+ %m2 = call i16 @llvm.umul.fix.i16(i16 %y, i16 %x, i32 1)
+ %r = sub i16 %m1, %m2
+ ret i16 %r
+}
+
+declare float @llvm.fma.f32(float, float, float)
+
+define float @fma(float %x, float %y) {
+; CHECK-LABEL: @fma(
+; CHECK-NEXT: [[M1:%.*]] = call float @llvm.fma.f32(float [[X:%.*]], float [[Y:%.*]], float 1.000000e+00)
+; CHECK-NEXT: [[M2:%.*]] = call float @llvm.fma.f32(float [[Y]], float [[X]], float 1.000000e+00)
+; CHECK-NEXT: [[R:%.*]] = fdiv nnan float [[M1]], [[M2]]
+; CHECK-NEXT: ret float [[R]]
+;
+ %m1 = call float @llvm.fma.f32(float %x, float %y, float 1.0)
+ %m2 = call float @llvm.fma.f32(float %y, float %x, float 1.0)
+ %r = fdiv nnan float %m1, %m2
+ ret float %r
+}
More information about the llvm-commits
mailing list