[llvm] r340926 - [InstCombine] remove unnecessary shuffle undef folding
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 29 06:24:34 PDT 2018
Author: spatel
Date: Wed Aug 29 06:24:34 2018
New Revision: 340926
URL: http://llvm.org/viewvc/llvm-project?rev=340926&view=rev
Log:
[InstCombine] remove unnecessary shuffle undef folding
Add a test for constant folding to show that
(shuffle undef, undef, mask)
should already be handled via instsimplify.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/trunk/test/Analysis/ConstantFolding/vector-undef-elts.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp?rev=340926&r1=340925&r2=340926&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Wed Aug 29 06:24:34 2018
@@ -1379,13 +1379,6 @@ Instruction *InstCombiner::visitShuffleV
// Canonicalize shuffle(x ,x,mask) -> shuffle(x, undef,mask')
// Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask').
if (LHS == RHS || isa<UndefValue>(LHS)) {
- if (isa<UndefValue>(LHS) && LHS == RHS) {
- // shuffle(undef,undef,mask) -> undef.
- Value *Result = (VWidth == LHSWidth)
- ? LHS : UndefValue::get(SVI.getType());
- return replaceInstUsesWith(SVI, Result);
- }
-
// Remap any references to RHS to use LHS.
SmallVector<Constant*, 16> Elts;
for (unsigned i = 0, e = LHSWidth; i != VWidth; ++i) {
Modified: llvm/trunk/test/Analysis/ConstantFolding/vector-undef-elts.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ConstantFolding/vector-undef-elts.ll?rev=340926&r1=340925&r2=340926&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/ConstantFolding/vector-undef-elts.ll (original)
+++ llvm/trunk/test/Analysis/ConstantFolding/vector-undef-elts.ll Wed Aug 29 06:24:34 2018
@@ -59,3 +59,11 @@ define <3 x float> @fadd_commute() {
ret <3 x float> %c
}
+define <4 x i32> @shuffle_of_undefs(<4 x i32> %v1, <4 x i32> %v2) {
+; CHECK-LABEL: @shuffle_of_undefs(
+; CHECK-NEXT: ret <4 x i32> undef
+;
+ %r = shufflevector <4 x i32> undef, <4 x i32> undef, <4 x i32> <i32 5, i32 1, i32 2, i32 3>
+ ret <4 x i32> %r
+}
+
More information about the llvm-commits
mailing list