[opaque pointer type] Add textual IR support for explicit type parameter to getelemen...
[oota-llvm.git] / test / Transforms / InstCombine / and2.ll
index 531aedb668a01b85ab381b52aa8e8a798edf30cd..96b535dda99d2ba9eb48c5f6544743105d6853d1 100644 (file)
@@ -13,7 +13,7 @@ define i1 @test2(i1 %X, i1 %Y) {
   %a = and i1 %X, %Y
   %b = and i1 %a, %X
   ret i1 %b
-; CHECK: @test2
+; CHECK-LABEL: @test2(
 ; CHECK-NEXT: and i1 %X, %Y
 ; CHECK-NEXT: ret
 }
@@ -22,7 +22,7 @@ define i32 @test3(i32 %X, i32 %Y) {
   %a = and i32 %X, %Y
   %b = and i32 %Y, %a
   ret i32 %b
-; CHECK: @test3
+; CHECK-LABEL: @test3(
 ; CHECK-NEXT: and i32 %X, %Y
 ; CHECK-NEXT: ret
 }
@@ -32,7 +32,7 @@ define i1 @test4(i32 %X) {
   %b = icmp slt i32 %X, 0
   %c = and i1 %a, %b
   ret i1 %c
-; CHECK: @test4
+; CHECK-LABEL: @test4(
 ; CHECK-NEXT: ret i1 false
 }
 
@@ -42,3 +42,38 @@ define <4 x i32> @test5(<4 x i32> %A) {
   %2 = and <4 x i32> <i32 1, i32 2, i32 3, i32 4>, %1
   ret <4 x i32> %2
 }
+
+; Check that we combine "if x!=0 && x!=-1" into "if x+1u>1"
+define i32 @test6(i64 %x) nounwind {
+; CHECK-LABEL: @test6(
+; CHECK-NEXT: add i64 %x, 1
+; CHECK-NEXT: icmp ugt i64 %x.off, 1
+  %cmp1 = icmp ne i64 %x, -1
+  %not.cmp = icmp ne i64 %x, 0
+  %.cmp1 = and i1 %cmp1, %not.cmp
+  %land.ext = zext i1 %.cmp1 to i32
+  ret i32 %land.ext
+}
+
+define i1 @test7(i32 %i, i1 %b) {
+; CHECK-LABEL: @test7(
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 %i, 0
+; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP]], %b
+; CHECK-NEXT: ret i1 [[AND]]
+  %cmp1 = icmp slt i32 %i, 1
+  %cmp2 = icmp sgt i32 %i, -1
+  %and1 = and i1 %cmp1, %b
+  %and2 = and i1 %and1, %cmp2
+  ret i1 %and2
+}
+
+define i1 @test8(i32 %i) {
+; CHECK-LABEL: @test8(
+; CHECK-NEXT: [[DEC:%.*]] = add i32 %i, -1
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[DEC]], 13
+; CHECK-NEXT: ret i1 [[CMP]]
+  %cmp1 = icmp ne i32 %i, 0
+  %cmp2 = icmp ult i32 %i, 14
+  %cond = and i1 %cmp1, %cmp2
+  ret i1 %cond
+}