[PATCH] D107793: [InstSimplify] Eliminate vector reverse of a splat vector
Usman Nadeem via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 9 17:25:45 PDT 2021
mnadeem created this revision.
Herald added a subscriber: hiraditya.
mnadeem requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
experimental.vector.reverse(splat(X)) -> splat(X)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D107793
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/named-vector-shuffle-reverse.ll
Index: llvm/test/Transforms/InstSimplify/named-vector-shuffle-reverse.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/named-vector-shuffle-reverse.ll
+++ llvm/test/Transforms/InstSimplify/named-vector-shuffle-reverse.ll
@@ -9,4 +9,17 @@
ret <vscale x 4 x i32> %rev.rev
}
+; Test reverse of a splat is eliminated.
+define <vscale x 4 x i32> @splat_reverse(i32 %a) {
+; CHECK-LABEL: @splat_reverse(
+; CHECK-NEXT: [[SPLAT_INSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[A:%.*]], i32 0
+; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[SPLAT_INSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT: ret <vscale x 4 x i32> [[SPLAT]]
+;
+ %splat_insert = insertelement <vscale x 4 x i32> poison, i32 %a, i32 0
+ %splat = shufflevector <vscale x 4 x i32> %splat_insert, <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
+ %rev = tail call <vscale x 4 x i32> @llvm.experimental.vector.reverse.nxv4i32(<vscale x 4 x i32> %splat)
+ ret <vscale x 4 x i32> %rev
+}
+
declare <vscale x 4 x i32> @llvm.experimental.vector.reverse.nxv4i32(<vscale x 4 x i32>)
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -5457,6 +5457,9 @@
if (match(Op0,
m_Intrinsic<Intrinsic::experimental_vector_reverse>(m_Value(X))))
return X;
+ // experimental.vector.reverse(splat(X)) -> splat(X)
+ if (isSplatValue(Op0))
+ return Op0;
break;
default:
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107793.365323.patch
Type: text/x-patch
Size: 1688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210810/df0bce25/attachment.bin>
More information about the llvm-commits
mailing list