[llvm] 73e1ba6 - [NFC] Added tests for PR51565
Dávid Bolvanský via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 4 05:38:53 PDT 2021
Author: Dávid Bolvanský
Date: 2021-09-04T14:38:43+02:00
New Revision: 73e1ba62158992e273fd4875cd11e07f64c81844
URL: https://github.com/llvm/llvm-project/commit/73e1ba62158992e273fd4875cd11e07f64c81844
DIFF: https://github.com/llvm/llvm-project/commit/73e1ba62158992e273fd4875cd11e07f64c81844.diff
LOG: [NFC] Added tests for PR51565
Added:
llvm/test/Transforms/InstCombine/icmp-rotate.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-rotate.ll b/llvm/test/Transforms/InstCombine/icmp-rotate.ll
new file mode 100644
index 0000000000000..cf670c79e7a4d
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/icmp-rotate.ll
@@ -0,0 +1,161 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+declare i8 @llvm.fshl.i8(i8, i8, i8)
+declare i8 @llvm.fshr.i8(i8, i8, i8)
+declare <2 x i5> @llvm.fshl.v2i5(<2 x i5>, <2 x i5>, <2 x i5>)
+declare <2 x i5> @llvm.fshr.v2i5(<2 x i5>, <2 x i5>, <2 x i5>)
+declare void @use(i8)
+
+define i1 @rol_eq(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @rol_eq(
+; CHECK-NEXT: [[F:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Z:%.*]])
+; CHECK-NEXT: [[F2:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[Y:%.*]], i8 [[Y]], i8 [[Z]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[F]], [[F2]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %f = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %z)
+ %f2 = tail call i8 @llvm.fshl.i8(i8 %y, i8 %y, i8 %z)
+ %r = icmp eq i8 %f, %f2
+ ret i1 %r
+}
+
+define i1 @rol_ne(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @rol_ne(
+; CHECK-NEXT: [[F:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Z:%.*]])
+; CHECK-NEXT: [[F2:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[Y:%.*]], i8 [[Y]], i8 [[Z]])
+; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[F]], [[F2]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %f = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %z)
+ %f2 = tail call i8 @llvm.fshl.i8(i8 %y, i8 %y, i8 %z)
+ %r = icmp ne i8 %f, %f2
+ ret i1 %r
+}
+
+define i1 @ror_eq(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @ror_eq(
+; CHECK-NEXT: [[F:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Z:%.*]])
+; CHECK-NEXT: [[F2:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[Y:%.*]], i8 [[Y]], i8 [[Z]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[F]], [[F2]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %f = tail call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 %z)
+ %f2 = tail call i8 @llvm.fshr.i8(i8 %y, i8 %y, i8 %z)
+ %r = icmp eq i8 %f, %f2
+ ret i1 %r
+}
+
+
+define i1 @ror_ne(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @ror_ne(
+; CHECK-NEXT: [[F:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Z:%.*]])
+; CHECK-NEXT: [[F2:%.*]] = tail call i8 @llvm.fshr.i8(i8 [[Y:%.*]], i8 [[Y]], i8 [[Z]])
+; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[F]], [[F2]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %f = tail call i8 @llvm.fshr.i8(i8 %x, i8 %x, i8 %z)
+ %f2 = tail call i8 @llvm.fshr.i8(i8 %y, i8 %y, i8 %z)
+ %r = icmp ne i8 %f, %f2
+ ret i1 %r
+}
+
+define i1 @rol_eq_use(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @rol_eq_use(
+; CHECK-NEXT: [[F:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Z:%.*]])
+; CHECK-NEXT: call void @use(i8 [[F]])
+; CHECK-NEXT: [[F2:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[Y:%.*]], i8 [[Y]], i8 [[Z]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[F]], [[F2]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %f = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %z)
+ call void @use(i8 %f)
+ %f2 = tail call i8 @llvm.fshl.i8(i8 %y, i8 %y, i8 %z)
+ %r = icmp eq i8 %f, %f2
+ ret i1 %r
+}
+
+define i1 @rol_eq_uses(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @rol_eq_uses(
+; CHECK-NEXT: [[F:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Z:%.*]])
+; CHECK-NEXT: call void @use(i8 [[F]])
+; CHECK-NEXT: [[F2:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[Y:%.*]], i8 [[Y]], i8 [[Z]])
+; CHECK-NEXT: call void @use(i8 [[F2]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[F]], [[F2]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %f = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %z)
+ call void @use(i8 %f)
+ %f2 = tail call i8 @llvm.fshl.i8(i8 %y, i8 %y, i8 %z)
+ call void @use(i8 %f2)
+ %r = icmp eq i8 %f, %f2
+ ret i1 %r
+}
+
+define <2 x i1> @rol_eq_vec(<2 x i5> %x, <2 x i5> %y, <2 x i5> %z) {
+; CHECK-LABEL: @rol_eq_vec(
+; CHECK-NEXT: [[F:%.*]] = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5> [[X:%.*]], <2 x i5> [[X]], <2 x i5> [[Z:%.*]])
+; CHECK-NEXT: [[F2:%.*]] = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5> [[Y:%.*]], <2 x i5> [[Y]], <2 x i5> [[Z]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i5> [[F]], [[F2]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %f = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5> %x, <2 x i5> %x, <2 x i5> %z)
+ %f2 = tail call <2 x i5> @llvm.fshl.v2i5(<2 x i5> %y, <2 x i5> %y, <2 x i5> %z)
+ %r = icmp eq <2 x i5> %f, %f2
+ ret <2 x i1> %r
+}
+
+define <2 x i1> @ror_eq_vec(<2 x i5> %x, <2 x i5> %y, <2 x i5> %z) {
+; CHECK-LABEL: @ror_eq_vec(
+; CHECK-NEXT: [[F:%.*]] = tail call <2 x i5> @llvm.fshr.v2i5(<2 x i5> [[X:%.*]], <2 x i5> [[X]], <2 x i5> [[Z:%.*]])
+; CHECK-NEXT: [[F2:%.*]] = tail call <2 x i5> @llvm.fshr.v2i5(<2 x i5> [[Y:%.*]], <2 x i5> [[Y]], <2 x i5> [[Z]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i5> [[F]], [[F2]]
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %f = tail call <2 x i5> @llvm.fshr.v2i5(<2 x i5> %x, <2 x i5> %x, <2 x i5> %z)
+ %f2 = tail call <2 x i5> @llvm.fshr.v2i5(<2 x i5> %y, <2 x i5> %y, <2 x i5> %z)
+ %r = icmp eq <2 x i5> %f, %f2
+ ret <2 x i1> %r
+}
+
+; negative test - not a rotate
+define i1 @no_rotate(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @no_rotate(
+; CHECK-NEXT: [[F:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[Y:%.*]], i8 [[Z:%.*]])
+; CHECK-NEXT: [[F2:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[Y]], i8 [[Y]], i8 [[Z]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[F]], [[F2]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %f = tail call i8 @llvm.fshl.i8(i8 %x, i8 %y, i8 %z)
+ %f2 = tail call i8 @llvm.fshl.i8(i8 %y, i8 %y, i8 %z)
+ %r = icmp eq i8 %f, %f2
+ ret i1 %r
+}
+
+; negative test - wrong predicate
+define i1 @wrong_pred(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @wrong_pred(
+; CHECK-NEXT: [[F:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Z:%.*]])
+; CHECK-NEXT: [[F2:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[Y:%.*]], i8 [[Y]], i8 [[Z]])
+; CHECK-NEXT: [[R:%.*]] = icmp ult i8 [[F]], [[F2]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %f = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %z)
+ %f2 = tail call i8 @llvm.fshl.i8(i8 %y, i8 %y, i8 %z)
+ %r = icmp ult i8 %f, %f2
+ ret i1 %r
+}
+
+; negative test - rotate amounts mismatch
+define i1 @amounts_mismatch(i8 %x, i8 %y, i8 %z, i8 %w) {
+; CHECK-LABEL: @amounts_mismatch(
+; CHECK-NEXT: [[F:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Z:%.*]])
+; CHECK-NEXT: [[F2:%.*]] = tail call i8 @llvm.fshl.i8(i8 [[Y:%.*]], i8 [[Y]], i8 [[W:%.*]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[F]], [[F2]]
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %f = tail call i8 @llvm.fshl.i8(i8 %x, i8 %x, i8 %z)
+ %f2 = tail call i8 @llvm.fshl.i8(i8 %y, i8 %y, i8 %w)
+ %r = icmp eq i8 %f, %f2
+ ret i1 %r
+}
More information about the llvm-commits
mailing list