summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Analysis/ValueTrackingTest.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2018-12-02 14:14:11 +0000
committerNikita Popov <nikita.ppv@gmail.com>2018-12-02 14:14:11 +0000
commit687b92cd9cf58e3405b906c7accd13bbdb813793 (patch)
tree4a0b4b5cc4bb3d9bcd47c005bd2e0ce3873bfbd7 /llvm/unittests/Analysis/ValueTrackingTest.cpp
parentb205606d3e52324827d94025df5a8427b3163f0a (diff)
downloadbcm5719-llvm-687b92cd9cf58e3405b906c7accd13bbdb813793.tar.gz
bcm5719-llvm-687b92cd9cf58e3405b906c7accd13bbdb813793.zip
[ValueTracking] Support funnel shifts in computeKnownBits()
If the shift amount is known, we can determine the known bits of the output based on the known bits of two inputs. This is essentially the same functionality as implemented in D54869, but for ValueTracking rather than InstCombine SimplifyDemandedBits. Differential Revision: https://reviews.llvm.org/D55140 llvm-svn: 348091
Diffstat (limited to 'llvm/unittests/Analysis/ValueTrackingTest.cpp')
-rw-r--r--llvm/unittests/Analysis/ValueTrackingTest.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp
index eeefb605867..5b36d63b390 100644
--- a/llvm/unittests/Analysis/ValueTrackingTest.cpp
+++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp
@@ -568,3 +568,51 @@ TEST_F(ComputeKnownBitsTest, ComputeKnownMulBits) {
"}\n");
expectKnownBits(/*zero*/ 95u, /*one*/ 32u);
}
+
+TEST_F(ComputeKnownBitsTest, ComputeKnownFshl) {
+ // fshl(....1111....0000, 00..1111........, 6)
+ // = 11....000000..11
+ parseAssembly(
+ "define i16 @test(i16 %a, i16 %b) {\n"
+ " %aa = shl i16 %a, 4\n"
+ " %bb = lshr i16 %b, 2\n"
+ " %aaa = or i16 %aa, 3840\n"
+ " %bbb = or i16 %bb, 3840\n"
+ " %A = call i16 @llvm.fshl.i16(i16 %aaa, i16 %bbb, i16 6)\n"
+ " ret i16 %A\n"
+ "}\n"
+ "declare i16 @llvm.fshl.i16(i16, i16, i16)\n");
+ expectKnownBits(/*zero*/ 1008u, /*one*/ 49155u);
+}
+
+TEST_F(ComputeKnownBitsTest, ComputeKnownFshr) {
+ // fshr(....1111....0000, 00..1111........, 26)
+ // = 11....000000..11
+ parseAssembly(
+ "define i16 @test(i16 %a, i16 %b) {\n"
+ " %aa = shl i16 %a, 4\n"
+ " %bb = lshr i16 %b, 2\n"
+ " %aaa = or i16 %aa, 3840\n"
+ " %bbb = or i16 %bb, 3840\n"
+ " %A = call i16 @llvm.fshr.i16(i16 %aaa, i16 %bbb, i16 26)\n"
+ " ret i16 %A\n"
+ "}\n"
+ "declare i16 @llvm.fshr.i16(i16, i16, i16)\n");
+ expectKnownBits(/*zero*/ 1008u, /*one*/ 49155u);
+}
+
+TEST_F(ComputeKnownBitsTest, ComputeKnownFshlZero) {
+ // fshl(....1111....0000, 00..1111........, 0)
+ // = ....1111....0000
+ parseAssembly(
+ "define i16 @test(i16 %a, i16 %b) {\n"
+ " %aa = shl i16 %a, 4\n"
+ " %bb = lshr i16 %b, 2\n"
+ " %aaa = or i16 %aa, 3840\n"
+ " %bbb = or i16 %bb, 3840\n"
+ " %A = call i16 @llvm.fshl.i16(i16 %aaa, i16 %bbb, i16 0)\n"
+ " ret i16 %A\n"
+ "}\n"
+ "declare i16 @llvm.fshl.i16(i16, i16, i16)\n");
+ expectKnownBits(/*zero*/ 15u, /*one*/ 3840u);
+}
OpenPOWER on IntegriCloud