[llvm] 7e6d318 - [InstCombine] move shuffle after funnel shift with same-shuffled operands
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed May 4 10:07:47 PDT 2022
Author: Sanjay Patel
Date: 2022-05-04T13:07:26-04:00
New Revision: 7e6d318c506bbbffb4f92cd8b70773beedc78c3e
URL: https://github.com/llvm/llvm-project/commit/7e6d318c506bbbffb4f92cd8b70773beedc78c3e
DIFF: https://github.com/llvm/llvm-project/commit/7e6d318c506bbbffb4f92cd8b70773beedc78c3e.diff
LOG: [InstCombine] move shuffle after funnel shift with same-shuffled operands
This extends 432c199e8473 and 9c4770eaab9d9 with an intrinsic
cited directly in issue #46238
Eventually, we will want to use llvm::isTriviallyVectorizable()
or create some new API for this list, but for now, I am intentionally
making a minimum change to reduce risk and only affect an intrinsic
with regression tests in place.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/fsh.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 485372c8b2c0d..f466f54e72b5c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1094,6 +1094,8 @@ foldShuffledIntrinsicOperands(IntrinsicInst *II,
case Intrinsic::umax:
case Intrinsic::umin:
case Intrinsic::fma:
+ case Intrinsic::fshl:
+ case Intrinsic::fshr:
break;
default:
return nullptr;
diff --git a/llvm/test/Transforms/InstCombine/fsh.ll b/llvm/test/Transforms/InstCombine/fsh.ll
index 8d5d5e004d970..8460fc840e589 100644
--- a/llvm/test/Transforms/InstCombine/fsh.ll
+++ b/llvm/test/Transforms/InstCombine/fsh.ll
@@ -740,10 +740,8 @@ define <2 x i31> @fshr_mask_args_same_vector3_
diff erent_but_still_prunable(<2 x
define <2 x i32> @fsh_unary_shuffle_ops(<2 x i32> %x, <2 x i32> %y, <2 x i32> %z) {
; CHECK-LABEL: @fsh_unary_shuffle_ops(
-; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x i32> [[X:%.*]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
-; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x i32> [[Y:%.*]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
-; CHECK-NEXT: [[C:%.*]] = shufflevector <2 x i32> [[Z:%.*]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
-; CHECK-NEXT: [[R:%.*]] = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> [[A]], <2 x i32> [[B]], <2 x i32> [[C]])
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> [[X:%.*]], <2 x i32> [[Y:%.*]], <2 x i32> [[Z:%.*]])
+; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> poison, <2 x i32> <i32 1, i32 0>
; CHECK-NEXT: ret <2 x i32> [[R]]
;
%a = shufflevector <2 x i32> %x, <2 x i32> poison, <2 x i32> <i32 1, i32 0>
@@ -757,9 +755,8 @@ define <3 x i16> @fsh_unary_shuffle_ops_widening(<2 x i16> %x, <2 x i16> %y, <2
; CHECK-LABEL: @fsh_unary_shuffle_ops_widening(
; CHECK-NEXT: [[A:%.*]] = shufflevector <2 x i16> [[X:%.*]], <2 x i16> poison, <3 x i32> <i32 1, i32 0, i32 1>
; CHECK-NEXT: call void @use_v3(<3 x i16> [[A]])
-; CHECK-NEXT: [[B:%.*]] = shufflevector <2 x i16> [[Y:%.*]], <2 x i16> poison, <3 x i32> <i32 1, i32 0, i32 1>
-; CHECK-NEXT: [[C:%.*]] = shufflevector <2 x i16> [[Z:%.*]], <2 x i16> poison, <3 x i32> <i32 1, i32 0, i32 1>
-; CHECK-NEXT: [[R:%.*]] = call <3 x i16> @llvm.fshl.v3i16(<3 x i16> [[A]], <3 x i16> [[B]], <3 x i16> [[C]])
+; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i16> @llvm.fshl.v2i16(<2 x i16> [[X]], <2 x i16> [[Y:%.*]], <2 x i16> [[Z:%.*]])
+; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x i16> [[TMP1]], <2 x i16> poison, <3 x i32> <i32 1, i32 0, i32 1>
; CHECK-NEXT: ret <3 x i16> [[R]]
;
%a = shufflevector <2 x i16> %x, <2 x i16> poison, <3 x i32> <i32 1, i32 0, i32 1>
@@ -772,11 +769,10 @@ define <3 x i16> @fsh_unary_shuffle_ops_widening(<2 x i16> %x, <2 x i16> %y, <2
define <2 x i31> @fsh_unary_shuffle_ops_narrowing(<3 x i31> %x, <3 x i31> %y, <3 x i31> %z) {
; CHECK-LABEL: @fsh_unary_shuffle_ops_narrowing(
-; CHECK-NEXT: [[A:%.*]] = shufflevector <3 x i31> [[X:%.*]], <3 x i31> poison, <2 x i32> <i32 1, i32 0>
; CHECK-NEXT: [[B:%.*]] = shufflevector <3 x i31> [[Y:%.*]], <3 x i31> poison, <2 x i32> <i32 1, i32 0>
; CHECK-NEXT: call void @use_v2(<2 x i31> [[B]])
-; CHECK-NEXT: [[C:%.*]] = shufflevector <3 x i31> [[Z:%.*]], <3 x i31> poison, <2 x i32> <i32 1, i32 0>
-; CHECK-NEXT: [[R:%.*]] = call <2 x i31> @llvm.fshl.v2i31(<2 x i31> [[A]], <2 x i31> [[B]], <2 x i31> [[C]])
+; CHECK-NEXT: [[TMP1:%.*]] = call <3 x i31> @llvm.fshl.v3i31(<3 x i31> [[X:%.*]], <3 x i31> [[Y]], <3 x i31> [[Z:%.*]])
+; CHECK-NEXT: [[R:%.*]] = shufflevector <3 x i31> [[TMP1]], <3 x i31> poison, <2 x i32> <i32 1, i32 0>
; CHECK-NEXT: ret <2 x i31> [[R]]
;
%a = shufflevector <3 x i31> %x, <3 x i31> poison, <2 x i32> <i32 1, i32 0>
More information about the llvm-commits
mailing list