Skip to content

Commit

Permalink
[ValueTracking] Shufflevector produces poison rather than undef
Browse files Browse the repository at this point in the history
Shufflevector semantics have changed so that poison mask elements
return poison rather than undef. Reflect this in the
canCreateUndefOrPoison() implementation.
  • Loading branch information
nikic committed Dec 21, 2023
1 parent 5992ce9 commit e414ba3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions llvm/lib/Analysis/ValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6674,9 +6674,6 @@ static bool canCreateUndefOrPoison(const Operator *Op, bool PoisonOnly,
return false;
}
case Instruction::ShuffleVector: {
// shufflevector may return undef.
if (PoisonOnly)
return false;
ArrayRef<int> Mask = isa<ConstantExpr>(Op)
? cast<ConstantExpr>(Op)->getShuffleMask()
: cast<ShuffleVectorInst>(Op)->getShuffleMask();
Expand Down
8 changes: 4 additions & 4 deletions llvm/unittests/Analysis/ValueTrackingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,12 +1177,12 @@ TEST(ValueTracking, canCreatePoisonOrUndef) {
{{false, false},
"shufflevector <4 x i32> %vx, <4 x i32> %vx2, "
"<4 x i32> <i32 0, i32 1, i32 2, i32 3>"},
{{false, true},
{{true, false},
"shufflevector <4 x i32> %vx, <4 x i32> %vx2, "
"<4 x i32> <i32 0, i32 1, i32 2, i32 undef>"},
{{false, true},
"<4 x i32> <i32 0, i32 1, i32 2, i32 poison>"},
{{true, false},
"shufflevector <vscale x 4 x i32> %svx, "
"<vscale x 4 x i32> %svx, <vscale x 4 x i32> undef"},
"<vscale x 4 x i32> %svx, <vscale x 4 x i32> poison"},
{{true, false}, "call i32 @g(i32 %x)"},
{{false, false}, "call noundef i32 @g(i32 %x)"},
{{true, false}, "fcmp nnan oeq float %fx, %fy"},
Expand Down

0 comments on commit e414ba3

Please sign in to comment.