Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2254,25 +2254,6 @@ Instruction *InstCombinerImpl::foldVectorBinop(BinaryOperator &Inst) {
}
NewVecC[ShMask[I]] = CElt;
}
// If this is a widening shuffle, we must be able to extend with poison
// elements. If the original binop does not produce a poison in the high
// lanes, then this transform is not safe.
// Similarly for poison lanes due to the shuffle mask, we can only
// transform binops that preserve poison.
// TODO: We could shuffle those non-poison constant values into the
// result by using a constant vector (rather than an poison vector)
// as operand 1 of the new binop, but that might be too aggressive
// for target-independent shuffle creation.
if (I >= SrcVecNumElts || ShMask[I] < 0) {
Constant *MaybePoison =
ConstOp1
? ConstantFoldBinaryOpOperands(Opcode, PoisonScalar, CElt, DL)
: ConstantFoldBinaryOpOperands(Opcode, CElt, PoisonScalar, DL);
if (!MaybePoison || !isa<PoisonValue>(MaybePoison)) {
MayChange = false;
break;
}
}
}
if (MayChange) {
Constant *NewC = ConstantVector::get(NewVecC);
Expand Down
7 changes: 5 additions & 2 deletions llvm/test/Transforms/InstCombine/vec_shuffle.ll
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,11 @@ define <4 x i16> @widening_shuffle_shl_constant_op1_non0(<2 x i16> %v) {
ret <4 x i16> %bo
}

; A binop that does not produce undef in the high lanes can not be moved before the shuffle.
; This is not ok because 'or -1, undef --> -1' but moving the shuffle results in undef instead.
; Previously, a shufflevector would produce an undef element from an undef mask
; index, which meant that pulling the shuffle out wasn't correct if the original
; binary op produced a non-undef result, e.g. or -1, undef --> -1.
;
; However nowadays shufflevector produces poison, which is safe to propagate.

define <4 x i16> @widening_shuffle_or(<2 x i16> %v) {
; CHECK-LABEL: @widening_shuffle_or(
Expand Down