[llvm] r302599 - [InstCombine] add tests for andn; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 16:40:13 PDT 2017


Author: spatel
Date: Tue May  9 18:40:13 2017
New Revision: 302599

URL: http://llvm.org/viewvc/llvm-project?rev=302599&view=rev
Log:
[InstCombine] add tests for andn; NFC

Modified:
    llvm/trunk/test/Transforms/InstCombine/add.ll

Modified: llvm/trunk/test/Transforms/InstCombine/add.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/add.ll?rev=302599&r1=302598&r2=302599&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/add.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/add.ll Tue May  9 18:40:13 2017
@@ -27,6 +27,34 @@ define <2 x i32> @select_0_or_1_from_boo
   ret <2 x i32> %add
 }
 
+; This is an 'andn' of the low bit.
+
+define i32 @flip_and_mask(i32 %x) {
+; CHECK-LABEL: @flip_and_mask(
+; CHECK-NEXT:    [[SHL:%.*]] = shl i32 %x, 31
+; CHECK-NEXT:    [[SHR:%.*]] = ashr exact i32 [[SHL]], 31
+; CHECK-NEXT:    [[INC:%.*]] = add nsw i32 [[SHR]], 1
+; CHECK-NEXT:    ret i32 [[INC]]
+;
+  %shl = shl i32 %x, 31
+  %shr = ashr i32 %shl, 31
+  %inc = add i32 %shr, 1
+  ret i32 %inc
+}
+
+define <2 x i8> @flip_and_mask_splat(<2 x i8> %x) {
+; CHECK-LABEL: @flip_and_mask_splat(
+; CHECK-NEXT:    [[SHL:%.*]] = shl <2 x i8> %x, <i8 7, i8 7>
+; CHECK-NEXT:    [[SHR:%.*]] = ashr exact <2 x i8> [[SHL]], <i8 7, i8 7>
+; CHECK-NEXT:    [[INC:%.*]] = add nsw <2 x i8> [[SHR]], <i8 1, i8 1>
+; CHECK-NEXT:    ret <2 x i8> [[INC]]
+;
+  %shl = shl <2 x i8> %x, <i8 7, i8 7>
+  %shr = ashr <2 x i8> %shl, <i8 7, i8 7>
+  %inc = add <2 x i8> %shr, <i8 1, i8 1>
+  ret <2 x i8> %inc
+}
+
 define i32 @test1(i32 %A) {
 ; CHECK-LABEL: @test1(
 ; CHECK-NEXT:    ret i32 %A




More information about the llvm-commits mailing list