]> granicus.if.org Git - llvm/commitdiff
[InstCombine] add tests for demanded bits ashr/lshr splat constants; NFC
authorSanjay Patel <spatel@rotateright.com>
Thu, 20 Apr 2017 20:44:54 +0000 (20:44 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 20 Apr 2017 20:44:54 +0000 (20:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300884 91177308-0d34-0410-b5e6-96231b3b80d8

test/Transforms/InstCombine/shift.ll

index 60ba35557f70a58f3c2dc96bf599d70a83b56c7a..72d361e8b6db334c333b1d0121c226208c7e1482 100644 (file)
@@ -1268,3 +1268,25 @@ define <2 x i64> @test_64_splat_vec(<2 x i32> %t) {
   ret <2 x i64> %shl
 }
 
+define <2 x i8> @ashr_demanded_bits_splat(<2 x i8> %x) {
+; CHECK-LABEL: @ashr_demanded_bits_splat(
+; CHECK-NEXT:    [[AND:%.*]] = and <2 x i8> %x, <i8 -128, i8 -128>
+; CHECK-NEXT:    [[SHR:%.*]] = ashr exact <2 x i8> [[AND]], <i8 7, i8 7>
+; CHECK-NEXT:    ret <2 x i8> [[SHR]]
+;
+  %and = and <2 x i8> %x, <i8 128, i8 128>
+  %shr = ashr <2 x i8> %and, <i8 7, i8 7>
+  ret <2 x i8> %shr
+}
+
+define <2 x i8> @lshr_demanded_bits_splat(<2 x i8> %x) {
+; CHECK-LABEL: @lshr_demanded_bits_splat(
+; CHECK-NEXT:    [[AND:%.*]] = and <2 x i8> %x, <i8 -128, i8 -128>
+; CHECK-NEXT:    [[SHR:%.*]] = lshr exact <2 x i8> [[AND]], <i8 7, i8 7>
+; CHECK-NEXT:    ret <2 x i8> [[SHR]]
+;
+  %and = and <2 x i8> %x, <i8 128, i8 128>
+  %shr = lshr <2 x i8> %and, <i8 7, i8 7>
+  ret <2 x i8> %shr
+}
+