Skip to content

Commit 783fd93

Browse files
committed
Merging r354144:
------------------------------------------------------------------------ r354144 | spatel | 2019-02-15 17:31:55 +0100 (Fri, 15 Feb 2019) | 3 lines [InstCombine] fix crash while trying to narrow a binop of shuffles (PR40734) https://bugs.llvm.org/show_bug.cgi?id=40734 ------------------------------------------------------------------------ llvm-svn: 354252
1 parent 25c79d9 commit 783fd93

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,8 @@ Instruction *InstCombiner::foldVectorBinop(BinaryOperator &Inst) {
13761376
if (match(LHS, m_ShuffleVector(m_Value(L0), m_Value(L1), m_Constant(Mask))) &&
13771377
match(RHS, m_ShuffleVector(m_Value(R0), m_Value(R1), m_Specific(Mask))) &&
13781378
LHS->hasOneUse() && RHS->hasOneUse() &&
1379-
cast<ShuffleVectorInst>(LHS)->isConcat()) {
1379+
cast<ShuffleVectorInst>(LHS)->isConcat() &&
1380+
cast<ShuffleVectorInst>(RHS)->isConcat()) {
13801381
// This transform does not have the speculative execution constraint as
13811382
// below because the shuffle is a concatenation. The new binops are
13821383
// operating on exactly the same elements as the existing binop.

llvm/test/Transforms/InstCombine/vec_shuffle.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,3 +1114,18 @@ define <2 x float> @frem_splat_constant1(<2 x float> %x) {
11141114
ret <2 x float> %r
11151115
}
11161116

1117+
; Equivalent shuffle masks, but only one is a narrowing op.
1118+
1119+
define <2 x i1> @PR40734(<1 x i1> %x, <4 x i1> %y) {
1120+
; CHECK-LABEL: @PR40734(
1121+
; CHECK-NEXT: [[WIDEN:%.*]] = shufflevector <1 x i1> zeroinitializer, <1 x i1> [[X:%.*]], <2 x i32> <i32 0, i32 1>
1122+
; CHECK-NEXT: [[NARROW:%.*]] = shufflevector <4 x i1> [[Y:%.*]], <4 x i1> undef, <2 x i32> <i32 0, i32 1>
1123+
; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[WIDEN]], [[NARROW]]
1124+
; CHECK-NEXT: ret <2 x i1> [[R]]
1125+
;
1126+
%widen = shufflevector <1 x i1> zeroinitializer, <1 x i1> %x, <2 x i32> <i32 0, i32 1>
1127+
%narrow = shufflevector <4 x i1> %y, <4 x i1> undef, <2 x i32> <i32 0, i32 1>
1128+
%r = and <2 x i1> %widen, %narrow
1129+
ret <2 x i1> %r
1130+
}
1131+

0 commit comments

Comments
 (0)