[llvm] 9696c8b - [InstCombine] Bail out on intrinsics with struct return types (#176556)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 17 04:04:42 PST 2026


Author: Yingwei Zheng
Date: 2026-01-17T12:04:37Z
New Revision: 9696c8bd620890387b258a116b9f244d91454627

URL: https://github.com/llvm/llvm-project/commit/9696c8bd620890387b258a116b9f244d91454627
DIFF: https://github.com/llvm/llvm-project/commit/9696c8bd620890387b258a116b9f244d91454627.diff

LOG: [InstCombine] Bail out on intrinsics with struct return types (#176556)

After https://github.com/llvm/llvm-project/pull/174835, overflow
intrinsics can be vectorized. But `foldShuffledIntrinsicOperands`
doesn't support shuffling vectors inside the struct return value.

Closes https://github.com/llvm/llvm-project/issues/176548.

Added: 
    llvm/test/Transforms/InstCombine/pr176548.ll

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index eee3d0f6f3e1d..b870ac259d3b0 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1486,7 +1486,8 @@ static Instruction *factorizeMinMaxTree(IntrinsicInst *II) {
 /// try to shuffle after the intrinsic.
 Instruction *
 InstCombinerImpl::foldShuffledIntrinsicOperands(IntrinsicInst *II) {
-  if (!isTriviallyVectorizable(II->getIntrinsicID()) ||
+  if (!II->getType()->isVectorTy() ||
+      !isTriviallyVectorizable(II->getIntrinsicID()) ||
       !II->getCalledFunction()->isSpeculatable())
     return nullptr;
 

diff  --git a/llvm/test/Transforms/InstCombine/pr176548.ll b/llvm/test/Transforms/InstCombine/pr176548.ll
new file mode 100644
index 0000000000000..115316efea05b
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/pr176548.ll
@@ -0,0 +1,32 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+
+; Make sure we don't pull shufflevector through an intrinsic that returns a struct.
+
+define { <4 x i32>, <4 x i1> } @sadd_ov_shuffle_ops(<4 x i32> %x) {
+; CHECK-LABEL: define { <4 x i32>, <4 x i1> } @sadd_ov_shuffle_ops(
+; CHECK-SAME: <4 x i32> [[X:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[SPLAT:%.*]] = shufflevector <4 x i32> [[X]], <4 x i32> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[OV:%.*]] = call { <4 x i32>, <4 x i1> } @llvm.sadd.with.overflow.v4i32(<4 x i32> [[SPLAT]], <4 x i32> splat (i32 1))
+; CHECK-NEXT:    ret { <4 x i32>, <4 x i1> } [[OV]]
+;
+entry:
+  %splat = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> zeroinitializer
+  %ov = call { <4 x i32>, <4 x i1> } @llvm.sadd.with.overflow.v4i32(<4 x i32> %splat, <4 x i32> splat (i32 1))
+  ret { <4 x i32>, <4 x i1> } %ov
+}
+
+define { <4 x float>, <4 x i32> } @frexp_ov_shuffle_ops(<4 x float> %x) {
+; CHECK-LABEL: define { <4 x float>, <4 x i32> } @frexp_ov_shuffle_ops(
+; CHECK-SAME: <4 x float> [[X:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[SPLAT:%.*]] = shufflevector <4 x float> [[X]], <4 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[OV:%.*]] = call { <4 x float>, <4 x i32> } @llvm.frexp.v4f32.v4i32(<4 x float> [[SPLAT]])
+; CHECK-NEXT:    ret { <4 x float>, <4 x i32> } [[OV]]
+;
+entry:
+  %splat = shufflevector <4 x float> %x, <4 x float> poison, <4 x i32> zeroinitializer
+  %ov = call { <4 x float>, <4 x i32> } @llvm.frexp(<4 x float> %splat)
+  ret { <4 x float>, <4 x i32> } %ov
+}


        


More information about the llvm-commits mailing list