[llvm] 7781f61 - [ConstantFold] Fix scalable shufflevector fold with all-undef mask
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 05:31:03 PST 2022
Author: Nikita Popov
Date: 2022-03-11T14:30:02+01:00
New Revision: 7781f61efa1823faadf73819785b8b8acd288914
URL: https://github.com/llvm/llvm-project/commit/7781f61efa1823faadf73819785b8b8acd288914
DIFF: https://github.com/llvm/llvm-project/commit/7781f61efa1823faadf73819785b8b8acd288914.diff
LOG: [ConstantFold] Fix scalable shufflevector fold with all-undef mask
If the input is scalable, we should not be returning a fixed-width
vector as a result.
Added:
Modified:
llvm/lib/IR/ConstantFold.cpp
llvm/test/Transforms/InstCombine/shufflevec-constant.ll
Removed:
################################################################################
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 936b1fc2ff6f3..74200b99367ca 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -724,7 +724,7 @@ Constant *llvm::ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2,
// Undefined shuffle mask -> undefined value.
if (all_of(Mask, [](int Elt) { return Elt == UndefMaskElem; })) {
- return UndefValue::get(FixedVectorType::get(EltTy, MaskNumElts));
+ return UndefValue::get(VectorType::get(EltTy, MaskEltCount));
}
// If the mask is all zeros this is a splat, no need to go through all
diff --git a/llvm/test/Transforms/InstCombine/shufflevec-constant.ll b/llvm/test/Transforms/InstCombine/shufflevec-constant.ll
index 9b8b678534d85..9b05185e868f1 100644
--- a/llvm/test/Transforms/InstCombine/shufflevec-constant.ll
+++ b/llvm/test/Transforms/InstCombine/shufflevec-constant.ll
@@ -1,4 +1,4 @@
-; NOTE: Assertions have been autogenerated by update_test_checks.py
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
@@ -15,3 +15,19 @@ define <4 x float> @__inff4() nounwind readnone {
%tmp9 = shufflevector <4 x float> zeroinitializer, <4 x float> %tmp8, <4 x i32> <i32 0, i32 1, i32 4, i32 5>
ret <4 x float> %tmp9
}
+
+define <4 x i1> @shuffle_undef_fixed() {
+; CHECK-LABEL: @shuffle_undef_fixed(
+; CHECK-NEXT: ret <4 x i1> undef
+;
+ %S = shufflevector <4 x i1> zeroinitializer, <4 x i1> zeroinitializer, <4 x i32> undef
+ ret <4 x i1> %S
+}
+
+define <vscale x 4 x i1> @suffle_undef_scalable() {
+; CHECK-LABEL: @suffle_undef_scalable(
+; CHECK-NEXT: ret <vscale x 4 x i1> undef
+;
+ %S = shufflevector <vscale x 4 x i1> zeroinitializer, <vscale x 4 x i1> zeroinitializer, <vscale x 4 x i32> undef
+ ret <vscale x 4 x i1> %S
+}
More information about the llvm-commits
mailing list