diff options
author | Justin Lebar <justin.lebar@gmail.com> | 2023-04-27 23:31:26 -0700 |
---|---|---|
committer | Justin Lebar <justin.lebar@gmail.com> | 2023-04-28 09:09:31 -0700 |
commit | 6f01cb91d763f740339683e1bde029e9f9f3bdf4 (patch) | |
tree | e9c5486373f855e1e3d1a9e63dbf34797bfbfafa /llvm/unittests/Analysis/ValueTrackingTest.cpp | |
parent | 8df5913250d55883feb8fa46a838c93a77c2e291 (diff) | |
download | llvm-6f01cb91d763f740339683e1bde029e9f9f3bdf4.zip llvm-6f01cb91d763f740339683e1bde029e9f9f3bdf4.tar.gz llvm-6f01cb91d763f740339683e1bde029e9f9f3bdf4.tar.bz2 |
Handle `select` in programUndefinedIfPoison.
If both the true and false operands of a `select` are poison, then the `select`
is poison.
Differential Revision: https://reviews.llvm.org/D149427
Diffstat (limited to 'llvm/unittests/Analysis/ValueTrackingTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/ValueTrackingTest.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp index 72d6387..6a8f468 100644 --- a/llvm/unittests/Analysis/ValueTrackingTest.cpp +++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp @@ -982,6 +982,20 @@ TEST_F(ValueTrackingTest, programUndefinedIfPoison) { EXPECT_EQ(programUndefinedIfPoison(A), true); } +TEST_F(ValueTrackingTest, programUndefinedIfPoisonSelect) { + parseAssembly("declare i32 @any_num()" + "define void @test(i1 %Cond) {\n" + " %A = call i32 @any_num()\n" + " %B = add i32 %A, 1\n" + " %C = select i1 %Cond, i32 %A, i32 %B\n" + " udiv i32 1, %C" + " ret void\n" + "}\n"); + // If A is poison, B is also poison, and therefore C is poison regardless of + // the value of %Cond. + EXPECT_EQ(programUndefinedIfPoison(A), true); +} + TEST_F(ValueTrackingTest, programUndefinedIfUndefOrPoison) { parseAssembly("declare i32 @any_num()" "define void @test(i32 %mask) {\n" |