1 ; This tests for various complex cast elimination cases instcombine should
4 ; RUN: opt < %s -instcombine -S | notcast
6 define i1 @test1(i32 %X) {
7 %A = bitcast i32 %X to i32 ; <i32> [#uses=1]
8 ; Convert to setne int %X, 12
9 %c = icmp ne i32 %A, 12 ; <i1> [#uses=1]
13 define i1 @test2(i32 %X, i32 %Y) {
14 %A = bitcast i32 %X to i32 ; <i32> [#uses=1]
15 %B = bitcast i32 %Y to i32 ; <i32> [#uses=1]
16 ; Convert to setne int %X, %Y
17 %c = icmp ne i32 %A, %B ; <i1> [#uses=1]
21 define i32 @test4(i32 %A) {
22 %B = bitcast i32 %A to i32 ; <i32> [#uses=1]
23 %C = shl i32 %B, 2 ; <i32> [#uses=1]
24 %D = bitcast i32 %C to i32 ; <i32> [#uses=1]
28 define i16 @test5(i16 %A) {
29 %B = sext i16 %A to i32 ; <i32> [#uses=1]
30 %C = and i32 %B, 15 ; <i32> [#uses=1]
31 %D = trunc i32 %C to i16 ; <i16> [#uses=1]
35 define i1 @test6(i1 %A) {
36 %B = zext i1 %A to i32 ; <i32> [#uses=1]
37 %C = icmp ne i32 %B, 0 ; <i1> [#uses=1]
41 define i1 @test6a(i1 %A) {
42 %B = zext i1 %A to i32 ; <i32> [#uses=1]
43 %C = icmp ne i32 %B, -1 ; <i1> [#uses=1]
47 define i1 @test7(i8* %A) {
48 %B = bitcast i8* %A to i32* ; <i32*> [#uses=1]
49 %C = icmp eq i32* %B, null ; <i1> [#uses=1]