1 ; Tests to make sure elimination of casts is working correctly 2 ; RUN: opt < %s -instcombine -S | FileCheck %s 3 4 define i64 @test_sext_zext(i16 %A) { 5 %c1 = zext i16 %A to i32 ; <i32> [#uses=1] 6 %c2 = sext i32 %c1 to i64 ; <i64> [#uses=1] 7 ret i64 %c2 8 9 ; CHECK-LABEL: @test_sext_zext 10 ; CHECK-NOT: %c1 11 ; CHECK: %c2 = zext i16 %A to i64 12 ; CHECK: ret i64 %c2 13 } 14 15 define <2 x i64> @test2(<2 x i1> %A) { 16 %xor = xor <2 x i1> %A, <i1 true, i1 true> 17 %zext = zext <2 x i1> %xor to <2 x i64> 18 ret <2 x i64> %zext 19 20 ; CHECK-LABEL: @test2 21 ; CHECK-NEXT: zext <2 x i1> %A to <2 x i64> 22 ; CHECK-NEXT: xor <2 x i64> %1, <i64 1, i64 1> 23 } 24 25 define <2 x i64> @test3(<2 x i64> %A) { 26 %trunc = trunc <2 x i64> %A to <2 x i32> 27 %and = and <2 x i32> %trunc, <i32 23, i32 42> 28 %zext = zext <2 x i32> %and to <2 x i64> 29 ret <2 x i64> %zext 30 31 ; CHECK-LABEL: @test3 32 ; CHECK-NEXT: and <2 x i64> %A, <i64 23, i64 42> 33 } 34 35 define <2 x i64> @test4(<2 x i64> %A) { 36 %trunc = trunc <2 x i64> %A to <2 x i32> 37 %and = and <2 x i32> %trunc, <i32 23, i32 42> 38 %xor = xor <2 x i32> %and, <i32 23, i32 42> 39 %zext = zext <2 x i32> %xor to <2 x i64> 40 ret <2 x i64> %zext 41 42 ; CHECK-LABEL: @test4 43 ; CHECK-NEXT: xor <2 x i64> %A, <i64 4294967295, i64 4294967295> 44 ; CHECK-NEXT: and <2 x i64> %1, <i64 23, i64 42> 45 } 46