[llvm] 7f5794c - [InstCombine] SimplifyDemandedVectorElts - add smulh/umulh handling (#228027)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 1 04:35:46 PDT 2026
Author: Simon Pilgrim
Date: 2026-10-01T11:35:37Z
New Revision: 7f5794c102a0caa350f6791e7ef541ec065d093f
URL: https://github.com/llvm/llvm-project/commit/7f5794c102a0caa350f6791e7ef541ec065d093f
DIFF: https://github.com/llvm/llvm-project/commit/7f5794c102a0caa350f6791e7ef541ec065d093f.diff
LOG: [InstCombine] SimplifyDemandedVectorElts - add smulh/umulh handling (#228027)
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/test/Transforms/InstCombine/smulh.ll
llvm/test/Transforms/InstCombine/umulh.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index bcd30323ce9a3..1f3107900dcd5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -1995,6 +1995,12 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
PoisonElts = PoisonElts2 & PoisonElts3;
break;
}
+ case Intrinsic::smulh:
+ case Intrinsic::umulh:
+ simplifyAndSetOp(II, 0, DemandedElts, PoisonElts);
+ simplifyAndSetOp(II, 1, DemandedElts, PoisonElts);
+ PoisonElts = PoisonElts2 | PoisonElts3;
+ break;
default: {
// Handle target specific intrinsics
std::optional<Value *> V = targetSimplifyDemandedVectorEltsIntrinsic(
diff --git a/llvm/test/Transforms/InstCombine/smulh.ll b/llvm/test/Transforms/InstCombine/smulh.ll
index a04d9faa0ddd5..f1ee17aeddeb3 100644
--- a/llvm/test/Transforms/InstCombine/smulh.ll
+++ b/llvm/test/Transforms/InstCombine/smulh.ll
@@ -191,9 +191,7 @@ define <32 x i16> @fold_smulh_v32i16() {
define <8 x i64> @elts_smulh_v8i64(<8 x i64> %a0, <8 x i64> %a1) {
; CHECK-LABEL: @elts_smulh_v8i64(
-; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <8 x i64> [[A0:%.*]], <8 x i64> poison, <8 x i32> <i32 0, i32 1, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2>
-; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <8 x i64> [[A1:%.*]], <8 x i64> poison, <8 x i32> <i32 0, i32 1, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6>
-; CHECK-NEXT: [[TMP3:%.*]] = call <8 x i64> @llvm.smulh.v8i64(<8 x i64> [[TMP1]], <8 x i64> [[TMP2]])
+; CHECK-NEXT: [[TMP3:%.*]] = call <8 x i64> @llvm.smulh.v8i64(<8 x i64> [[TMP1:%.*]], <8 x i64> [[TMP2:%.*]])
; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <8 x i64> [[TMP3]], <8 x i64> poison, <8 x i32> zeroinitializer
; CHECK-NEXT: ret <8 x i64> [[TMP4]]
;
diff --git a/llvm/test/Transforms/InstCombine/umulh.ll b/llvm/test/Transforms/InstCombine/umulh.ll
index f2e2c3f54df2e..85b069a518520 100644
--- a/llvm/test/Transforms/InstCombine/umulh.ll
+++ b/llvm/test/Transforms/InstCombine/umulh.ll
@@ -187,9 +187,7 @@ define <32 x i16> @fold_umulh_v32i16() {
define <8 x i64> @elts_umulh_v8i64(<8 x i64> %a0, <8 x i64> %a1) {
; CHECK-LABEL: @elts_umulh_v8i64(
-; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <8 x i64> [[A0:%.*]], <8 x i64> poison, <8 x i32> <i32 0, i32 1, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2>
-; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <8 x i64> [[A1:%.*]], <8 x i64> poison, <8 x i32> <i32 0, i32 1, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6>
-; CHECK-NEXT: [[TMP3:%.*]] = call <8 x i64> @llvm.umulh.v8i64(<8 x i64> [[TMP1]], <8 x i64> [[TMP2]])
+; CHECK-NEXT: [[TMP3:%.*]] = call <8 x i64> @llvm.umulh.v8i64(<8 x i64> [[TMP1:%.*]], <8 x i64> [[TMP2:%.*]])
; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <8 x i64> [[TMP3]], <8 x i64> poison, <8 x i32> zeroinitializer
; CHECK-NEXT: ret <8 x i64> [[TMP4]]
;
More information about the llvm-commits
mailing list