Canonicalize addrspacecast ConstExpr between different pointer types
[oota-llvm.git] / test / Transforms / InstCombine / zext.ll
index 7835fe690b2de21e899f7938a2ef9b3465b93b3d..b62c626c95c0bdf5b445885e7dd9a9dae2d1e2df 100644 (file)
@@ -1,9 +1,45 @@
 ; Tests to make sure elimination of casts is working correctly
-; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output &&
-; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | notcast '' '%c1.*'
+; RUN: opt < %s -instcombine -S | FileCheck %s
 
-long %test_sext_zext(short %A) {
-    %c1 = zext short %A to uint
-    %c2 = sext uint %c1 to long
-    ret long %c2
+define i64 @test_sext_zext(i16 %A) {
+        %c1 = zext i16 %A to i32                ; <i32> [#uses=1]
+        %c2 = sext i32 %c1 to i64               ; <i64> [#uses=1]
+        ret i64 %c2
+
+; CHECK-LABEL: @test_sext_zext
+; CHECK-NOT: %c1
+; CHECK: %c2 = zext i16 %A to i64
+; CHECK: ret i64 %c2
+}
+
+define <2 x i64> @test2(<2 x i1> %A) {
+  %xor = xor <2 x i1> %A, <i1 true, i1 true>
+  %zext = zext <2 x i1> %xor to <2 x i64>
+  ret <2 x i64> %zext
+
+; CHECK-LABEL: @test2
+; CHECK-NEXT: zext <2 x i1> %A to <2 x i64>
+; CHECK-NEXT: xor <2 x i64> %1, <i64 1, i64 1>
+}
+
+define <2 x i64> @test3(<2 x i64> %A) {
+  %trunc = trunc <2 x i64> %A to <2 x i32>
+  %and = and <2 x i32> %trunc, <i32 23, i32 42>
+  %zext = zext <2 x i32> %and to <2 x i64>
+  ret <2 x i64> %zext
+
+; CHECK-LABEL: @test3
+; CHECK-NEXT: and <2 x i64> %A, <i64 23, i64 42>
+}
+
+define <2 x i64> @test4(<2 x i64> %A) {
+  %trunc = trunc <2 x i64> %A to <2 x i32>
+  %and = and <2 x i32> %trunc, <i32 23, i32 42>
+  %xor = xor <2 x i32> %and, <i32 23, i32 42>
+  %zext = zext <2 x i32> %xor to <2 x i64>
+  ret <2 x i64> %zext
+
+; CHECK-LABEL: @test4
+; CHECK-NEXT: xor <2 x i64> %A, <i64 4294967295, i64 4294967295>
+; CHECK-NEXT: and <2 x i64> %1, <i64 23, i64 42>
 }