llvm.org GIT mirror llvm / eacb702
For PR950: Update the test suite to accommodate the change from signed integer types to signless integer types. The changes were of only a few kinds: 1. Make sure llvm-upgrade is run on the source which does the bulk of the changes automatically. 2. Change things like "grep 'int'" to "grep 'i32'" 3. In several tests bitcasting caused the same name to be reused in the same type plane. These had to be manually fixed. The fix was (generally) to leave the bitcast and provide the instruction with a new name. This should not affect the semantics of the test. In a few cases, the bitcasts were known to be superfluous and irrelevant to the test case so they were removed. 4. One test case uses a bytecode file which needed to be updated to the latest bytecode format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32789 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 12 years ago
117 changed file(s) with 285 addition(s) and 299 deletion(s). Raw diff Collapse all Expand all
None ; RUN: llvm-upgrade < %s | llvm-as | opt -dse | llvm-dis | grep 'store int 0'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -dse | llvm-dis | grep 'store i32 0'
11
22 void %test({int,int }* %P) {
33 %Q = getelementptr {int,int}* %P, int 1
None ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | grep 'load int\* %A'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | grep 'load i32\* %A'
11
22 declare double* %useit(int*)
33
None ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | grep 'ret int 0'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | grep 'ret i32 0'
11 declare void %foo(int*)
22 declare void %bar()
33
None ; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse -instcombine | llvm-dis | grep 'ret int 0'
0 ; RUN: llvm-upgrade < %s | llvm-as | \
1 ; RUN: opt -globalsmodref-aa -load-vn -gcse -instcombine | llvm-dis | \
2 ; RUN: grep 'ret i32 0'
13 %G = internal global int* null
24
35 implementation
0 ; Check to make sure that Value Numbering doesn't merge casts of different
11 ; flavors.
22 ; RUN: llvm-upgrade < %s | llvm-as | opt -load-vn -gcse | llvm-dis | \
3 ; RUN: grep '[sz]ext' | wc -l | grep 2
3 ; RUN: grep '[sz]ext' | wc -l | grep 2
44
55 declare void %external(int)
66
0 ; This file takes about 48 __MINUTES__ to assemble using as. This is WAY too
11 ; long. The type resolution code needs to be sped up a lot.
2 ; RUN: ulimit -t 20; llvm-as < %s
2 ; RUN: ulimit -t 20; llvm-upgrade < %s | llvm-as
33
44 %ALL_INTERSECTIONS_METHOD = type int (%OBJECT*, %RAY*, %ISTACK*)*
55 %BBOX = type { %BBOX_VECT, %BBOX_VECT }
None ; RUN: (llvm-as < %s 2>&1) | grep Expected
0 ; RUN: llvm-upgrade < %s | llvm-as 2>&1 >/dev/null | grep Expected
11 ; Test the case of a misformed constant initializer
22 ; This should cause an assembler error, not an assertion failure!
33 %X = constant {int} { float 1.0 }
0 ; Found by inspection of the code
1 ; RUN: llvm-upgrade < %s | llvm-as -o /dev/null -f 2>&1 | grep "Shift constant expression"
1 ; RUN: llvm-upgrade < %s | llvm-as 2>&1 > /dev/null | grep "Shift constant expression"
22
33 global int shr (float 1.0, ubyte 2)
0 ; Found by inspection of the code
1 ; RUN: llvm-as < %s 2>&1 | grep "Illegal"
1 ; RUN: llvm-upgrade < %s | llvm-as 2>&1 > /dev/null | grep "Illegal"
22
33 global {} { int 7, float 1.0, int 7, int 8 }
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis | grep ' bitcast ('
0 ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis | not grep ' bitcast ('
11
22 %.Base64_1 = external constant [4 x sbyte]
33
4 ubyte %test(sbyte %X) { ; No predecessors!
5 %X = cast sbyte %X to ubyte ; [#uses=1]
4 ubyte %test(sbyte %Y) { ; No predecessors!
5 %X = cast sbyte %Y to ubyte ; [#uses=1]
66 %tmp.13 = add ubyte %X, cast (sbyte sub (sbyte 0, sbyte cast ([4 x sbyte]* %.Base64_1 to sbyte)) to ubyte) ; [#uses=1]
77 ret ubyte %tmp.13
88 }
None ; RUN: llvm-as < %s 2>&1 | grep 'Reference to an undefined type'
0 ; RUN: llvm-upgrade < %s | llvm-as -o /dev/null -f 2>&1 | \
1 ; RUN: grep 'Reference to an undefined type'
12
23
34 %d_reduction_0_dparser_gram = global { int (sbyte*, sbyte**, int, int, { %struct.Grammar*, void (\4, %struct.d_loc_t*, sbyte**)*, %struct.D_Scope*, void (\4)*, { int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\8, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }* (\4, int, { int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\9, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }**)*, void ({ int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\8, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }*)*, %struct.d_loc_t, int, int, int, int, int, int, int, int, int, int, int, int }*)*, int (sbyte*, sbyte**, int, int, { %struct.Grammar*, void (\4, %struct.d_loc_t*, sbyte**)*, %struct.D_Scope*, void (\4)*, { int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\8, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }* (\4, int, { int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\9, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }**)*, void ({ int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\8, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }*)*, %struct.d_loc_t, int, int, int, int, int, int, int, int, int, int, int, int }*)** } { int (sbyte*, sbyte**, int, int, { %struct.Grammar*, void (\4, %struct.d_loc_t*, sbyte**)*, %struct.D_Scope*, void (\4)*, { int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\8, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }* (\4, int, { int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\9, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }**)*, void ({ int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\8, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }*)*, %struct.d_loc_t, int, int, int, int, int, int, int, int, int, int, int, int }*)* null, int (sbyte*, sbyte**, int, int, { %struct.Grammar*, void (\4, %struct.d_loc_t*, sbyte**)*, %struct.D_Scope*, void (\4)*, { int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\8, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }* (\4, int, { int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\9, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }**)*, void ({ int, %struct.d_loc_t, sbyte*, sbyte*, %struct.D_Scope*, void (\8, %struct.d_loc_t*, sbyte**)*, %struct.Grammar*, %struct.ParseNode_User }*)*, %struct.d_loc_t, int, int, int, int, int, int, int, int, int, int, int, int }*)** null }
0 ;; The bytecode writer was trying to treat undef values as ConstantArray's when
11 ;; they looked like strings.
2 ;; RUN: llvm-as < %s -o /dev/null -f
2 ;; RUN: llvm-upgrade < %s | llvm-as -o /dev/null -f
33 %G = internal global [8 x sbyte] undef
44
0 // XFAIL: llvmgcc3
1 // RUN: %llvmgxx -O0 -emit-llvm -S -g -o - %s | grep 'uint 1,' &&
2 // RUN: %llvmgxx -O0 -emit-llvm -S -g -o - %s | grep 'uint 2,'
1 // RUN: %llvmgxx -O0 -emit-llvm -S -g -o - %s | grep 'i32 1,' &&
2 // RUN: %llvmgxx -O0 -emit-llvm -S -g -o - %s | grep 'i32 2,'
33
44 class A {
55 public:
None // RUN: %llvmgcc %s -S -g -o - | grep 'llvm.dbg.stoppoint.*uint 14'
0 // RUN: %llvmgcc %s -S -g -o - | grep 'llvm.dbg.stoppoint.*i32 14'
11 // PR664: ensure that line #'s are emitted for declarations
22
33
None // RUN: %llvmgcc -S %s -o - | grep 'llvm.ctlz.i32(uint' &&
1 // RUN: %llvmgcc -S %s -o - | not grep 'llvm.ctlz.i32(int'
0 // RUN: %llvmgcc -S %s -o - | grep 'llvm.ctlz.i32(i32'
1 // RUNMEIFWEHADSIGNEDTYPES: %llvmgcc -S %s -o - | not grep 'llvm.ctlz.i32(i32'
22
33 unsigned t2(unsigned X) {
44 return __builtin_clz(X);
None // RUN: %llvmgcc %s -S -o - | gccas | llvm-dis | grep nate | grep 'global int 0'
0 // RUN: %llvmgcc %s -S -o - | gccas | llvm-dis | grep nate | grep 'global i32 0'
11
22 struct X { int *XX; int Y;};
33
22
33 implementation ; Functions:
44
5 void %f(int %a, ...) {
5 void %f(int %a_arg, ...) {
66 entry:
7 %a = cast int %a to uint ; [#uses=1]
7 %a = cast int %a_arg to uint ; [#uses=1]
88 %l1 = alloca sbyte*, align 4 ; [#uses=5]
99 %l2 = alloca sbyte*, align 4 ; [#uses=4]
1010 %memtmp = alloca sbyte* ; [#uses=2]
1111 call void %llvm.va_start( sbyte** %l1 )
12 %tmp22 = seteq int %a, 0 ; [#uses=1]
12 %tmp22 = seteq int %a_arg, 0 ; [#uses=1]
1313 %tmp23 = volatile load sbyte** %l1 ; [#uses=2]
1414 br bool %tmp22, label %bb8, label %bb
1515
0 ; Make sure this testcase codegens to the bic instruction
1 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=alpha | grep 'zapnot'
1 ; RUN: llvm-as < %s | llc -march=alpha | grep 'zapnot'
22
33 implementation ; Functions:
44
5 ushort %foo(long %y) {
5 define i16 @zext %foo(i64 %y) {
66 entry:
7 %tmp.1 = cast long %y to ushort ; [#uses=1]
8 ret ushort %tmp.1
7 %tmp.1 = trunc i64 %y to i16 ; [#uses=1]
8 ret i16 %tmp.1
99 }
10
0 ; RUN: llvm-upgrade < %s | llvm-as | llc
1 float %t(long %u) {
2 %u = cast long %u to ulong ; [#uses=1]
1 float %t(long %u_arg) {
2 %u = cast long %u_arg to ulong ; [#uses=1]
33 %tmp5 = add ulong %u, 9007199254740991 ; [#uses=1]
44 %tmp = setgt ulong %tmp5, 18014398509481982 ; [#uses=1]
55 br bool %tmp, label %T, label %F
238238 ret void
239239
240240 bb1876: ; preds = %bb1808
241 %tmp1877 = load int* %which_alternative ; [#uses=4]
242 %tmp1877 = cast int %tmp1877 to uint ; [#uses=1]
241 %tmp1877signed = load int* %which_alternative ; [#uses=4]
242 %tmp1877 = cast int %tmp1877signed to uint ; [#uses=1]
243243 %bothcond699 = setlt uint %tmp1877, 2 ; [#uses=1]
244 %tmp1888 = seteq int %tmp1877, 2 ; [#uses=1]
244 %tmp1888 = seteq int %tmp1877signed, 2 ; [#uses=1]
245245 %bothcond700 = or bool %bothcond699, %tmp1888 ; [#uses=1]
246246 %bothcond700.not = xor bool %bothcond700, true ; [#uses=1]
247 %tmp1894 = seteq int %tmp1877, 3 ; [#uses=1]
247 %tmp1894 = seteq int %tmp1877signed, 3 ; [#uses=1]
248248 %bothcond701 = or bool %tmp1894, %bothcond700.not ; [#uses=1]
249249 %bothcond702 = or bool %bothcond701, false ; [#uses=1]
250250 br bool %bothcond702, label %UnifiedReturnBlock, label %cond_next1902
251251
252252 cond_next1902: ; preds = %bb1876
253 switch int %tmp1877, label %cond_next1937 [
253 switch int %tmp1877signed, label %cond_next1937 [
254254 int 0, label %bb1918
255255 int 1, label %bb1918
256256 int 2, label %bb1918
1818 ]
1919
2020 bb7: ; preds = %bb, %bb
21 %tmp = cast sbyte %tmp to ubyte ; [#uses=1]
2221 tail call void %foo( ubyte %tmp )
2322 ret sbyte* %tmp2
2423 }
0 ; RUN: llvm-upgrade < %s | llvm-as | llc
11
22 void %iterative_hash_host_wide_int() {
3 %zero = alloca int ; [#uses=2]
4 %b = alloca uint ; [#uses=1]
3 %zero = alloca int ; [#uses=2]
4 %b = alloca uint ; [#uses=1]
55 store int 0, int* %zero
6 %tmp = load int* %zero ; [#uses=1]
6 %tmp = load int* %zero ; [#uses=1]
77 %tmp5 = cast int %tmp to uint ; [#uses=1]
8 %tmp6 = add uint %tmp5, 32 ; [#uses=1]
9 %tmp6 = cast uint %tmp6 to int ; [#uses=1]
10 %tmp7 = load long* null ; > [#uses=1]
8 %tmp6.u = add uint %tmp5, 32 ; > [#uses=1]
9 %tmp6 = cast uint %tmp6.u to int ; [#uses=1]
10 %tmp7 = load long* null ; [#uses=1]
1111 %tmp6 = cast int %tmp6 to ubyte ; [#uses=1]
12 %tmp8 = shr long %tmp7, ubyte %tmp6 ; [#uses=1]
12 %tmp8 = shr long %tmp7, ubyte %tmp6 ; [#uses=1]
1313 %tmp8 = cast long %tmp8 to uint ; [#uses=1]
1414 store uint %tmp8, uint* %b
1515 unreachable
99 ret void
1010 }
1111
12 ushort %test2(ushort %crc) { ; No and's should be needed for the ushorts here.
12 ushort @zext %test2(ushort @zext %crc) {
13 ; No and's should be needed for the ushorts here.
1314 %tmp.1 = shr ushort %crc, ubyte 1
1415 %tmp.7 = xor ushort %tmp.1, 40961
1516 ret ushort %tmp.7
88
99 void %foo(int %W, int %X, int %Y, int %Z) {
1010 entry:
11 %X = cast int %X to uint ; [#uses=1]
12 %Y = cast int %Y to uint ; [#uses=1]
13 %Z = cast int %Z to uint ; [#uses=1]
14 %W = cast int %W to uint ; [#uses=1]
11 %X.u = cast int %X to uint ; [#uses=1]
12 %Y.u = cast int %Y to uint ; [#uses=1]
13 %Z.u = cast int %Z to uint ; [#uses=1]
14 %W.u = cast int %W to uint ; [#uses=1]
1515 %tmp1 = and int %W, 1 ; [#uses=1]
1616 %tmp1 = seteq int %tmp1, 0 ; [#uses=1]
1717 br bool %tmp1, label %cond_false, label %bb5
2020 %indvar77 = phi uint [ %indvar.next78, %bb ], [ 0, %bb5 ] ; [#uses=1]
2121 %tmp2 = tail call int (...)* %bar( ) ; [#uses=0]
2222 %indvar.next78 = add uint %indvar77, 1 ; [#uses=2]
23 %exitcond79 = seteq uint %indvar.next78, %X ; [#uses=1]
23 %exitcond79 = seteq uint %indvar.next78, %X.u ; [#uses=1]
2424 br bool %exitcond79, label %cond_next48, label %bb
2525
2626 bb5: ; preds = %entry
3636 %indvar72 = phi uint [ %indvar.next73, %bb12 ], [ 0, %bb16 ] ; [#uses=1]
3737 %tmp13 = tail call int (...)* %bar( ) ; [#uses=0]
3838 %indvar.next73 = add uint %indvar72, 1 ; [#uses=2]
39 %exitcond74 = seteq uint %indvar.next73, %Y ; [#uses=1]
39 %exitcond74 = seteq uint %indvar.next73, %Y.u ; [#uses=1]
4040 br bool %exitcond74, label %cond_next48, label %bb12
4141
4242 bb16: ; preds = %cond_false
5252 %indvar67 = phi uint [ %indvar.next68, %bb25 ], [ 0, %bb29 ] ; [#uses=1]
5353 %tmp26 = tail call int (...)* %bar( ) ; [#uses=0]
5454 %indvar.next68 = add uint %indvar67, 1 ; [#uses=2]
55 %exitcond69 = seteq uint %indvar.next68, %Z ; [#uses=1]
55 %exitcond69 = seteq uint %indvar.next68, %Z.u ; [#uses=1]
5656 br bool %exitcond69, label %cond_next48, label %bb25
5757
5858 bb29: ; preds = %cond_false20
7171
7272 bb42: ; preds = %cond_false33, %bb38
7373 %indvar = phi uint [ %indvar.next, %bb38 ], [ 0, %cond_false33 ] ; [#uses=3]
74 %indvar = cast uint %indvar to int ; [#uses=1]
7574 %W_addr.0 = sub int %W, %indvar ; [#uses=1]
76 %exitcond = seteq uint %indvar, %W ; [#uses=1]
75 %exitcond = seteq uint %indvar, %W.u ; [#uses=1]
7776 br bool %exitcond, label %cond_next48, label %bb38
7877
7978 cond_next48: ; preds = %bb, %bb12, %bb25, %bb42, %cond_false33, %bb29, %bb16, %bb5
66 int %rotlw(uint %x, int %sh) {
77 entry:
88 %tmp.3 = cast int %sh to ubyte ; [#uses=1]
9 %x = cast uint %x to int ; [#uses=1]
9 %x.s = cast uint %x to int ; [#uses=1]
1010 %tmp.7 = sub int 32, %sh ; [#uses=1]
1111 %tmp.9 = cast int %tmp.7 to ubyte ; [#uses=1]
1212 %tmp.10 = shr uint %x, ubyte %tmp.9 ; [#uses=1]
13 %tmp.4 = shl int %x, ubyte %tmp.3 ; [#uses=1]
14 %tmp.10 = cast uint %tmp.10 to int ; [#uses=1]
13 %tmp.4 = shl int %x.s, ubyte %tmp.3 ; [#uses=1]
1514 %tmp.12 = or int %tmp.10, %tmp.4 ; [#uses=1]
1615 ret int %tmp.12
1716 }
2221 %tmp.4 = shr uint %x, ubyte %tmp.3 ; [#uses=1]
2322 %tmp.7 = sub int 32, %sh ; [#uses=1]
2423 %tmp.9 = cast int %tmp.7 to ubyte ; [#uses=1]
25 %x = cast uint %x to int ; [#uses=1]
26 %tmp.4 = cast uint %tmp.4 to int ; [#uses=1]
27 %tmp.10 = shl int %x, ubyte %tmp.9 ; [#uses=1]
24 %x.s = cast uint %x to int ; [#uses=1]
25 %tmp.10 = shl int %x.s, ubyte %tmp.9 ; [#uses=1]
2826 %tmp.12 = or int %tmp.4, %tmp.10 ; [#uses=1]
2927 ret int %tmp.12
3028 }
3129
3230 int %rotlwi(uint %x) {
3331 entry:
34 %x = cast uint %x to int ; [#uses=1]
32 %x.s = cast uint %x to int ; [#uses=1]
3533 %tmp.7 = shr uint %x, ubyte 27 ; [#uses=1]
36 %tmp.3 = shl int %x, ubyte 5 ; [#uses=1]
37 %tmp.7 = cast uint %tmp.7 to int ; [#uses=1]
34 %tmp.3 = shl int %x.s, ubyte 5 ; [#uses=1]
3835 %tmp.9 = or int %tmp.3, %tmp.7 ; [#uses=1]
3936 ret int %tmp.9
4037 }
4239 int %rotrwi(uint %x) {
4340 entry:
4441 %tmp.3 = shr uint %x, ubyte 5 ; [#uses=1]
45 %x = cast uint %x to int ; [#uses=1]
46 %tmp.3 = cast uint %tmp.3 to int ; [#uses=1]
47 %tmp.7 = shl int %x, ubyte 27 ; [#uses=1]
42 %x.s = cast uint %x to int ; [#uses=1]
43 %tmp.7 = shl int %x.s, ubyte 27 ; [#uses=1]
4844 %tmp.9 = or int %tmp.3, %tmp.7 ; [#uses=1]
4945 ret int %tmp.9
5046 }
None
1 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 &&
21 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=ppc32 | not grep 'extsh\|rlwinm'
32
4 declare short %foo()
3 declare short @sext %foo()
54
6 int %test1(short %X) {
5 int %test1(short @sext %X) {
76 %Y = cast short %X to int ;; dead
87 ret int %Y
98 }
109
11 int %test2(ushort %X) {
10 int %test2(ushort @zext %X) {
1211 %Y = cast ushort %X to int
1312 %Z = and int %Y, 65535 ;; dead
1413 ret int %Z
4746 ret uint %tmp.2
4847 }
4948
50 ushort %test7(float %a) {
49 ushort @zext %test7(float %a) {
5150 %tmp.1 = cast float %a to ushort
5251 ret ushort %tmp.1
5352 }
54
6161 void %spltish(<16 x ubyte>* %A, <16 x ubyte>* %B) {
6262 ; Gets converted to 16 x ubyte
6363 %tmp = load <16 x ubyte>* %B
64 %tmp = cast <16 x ubyte> %tmp to <16 x sbyte>
65 %tmp4 = sub <16 x sbyte> %tmp, cast (<8 x short> < short 15, short 15, short 15, short 15, short 15, short 15, short 15, short 15 > to <16 x sbyte>)
66 %tmp4 = cast <16 x sbyte> %tmp4 to <16 x ubyte>
67 store <16 x ubyte> %tmp4, <16 x ubyte>* %A
64 %tmp.s = cast <16 x ubyte> %tmp to <16 x sbyte>
65 %tmp4 = sub <16 x sbyte> %tmp.s, cast (<8 x short> < short 15, short 15, short 15, short 15, short 15, short 15, short 15, short 15 > to <16 x sbyte>)
66 %tmp4.u = cast <16 x sbyte> %tmp4 to <16 x ubyte>
67 store <16 x ubyte> %tmp4.u, <16 x ubyte>* %A
6868 ret void
6969 }
7070
1010 %tmp4 = getelementptr ubyte* %tmp, uint %tmp3 ; [#uses=1]
1111 %tmp7 = load uint* %tmp ; [#uses=1]
1212 %tmp8 = getelementptr ubyte* %tmp, uint %tmp7 ; [#uses=1]
13 %tmp8 = cast ubyte* %tmp8 to sbyte* ; [#uses=1]
14 %tmp4 = cast ubyte* %tmp4 to sbyte* ; [#uses=1]
15 %tmp = tail call int %memcmp( sbyte* %tmp8, sbyte* %tmp4, uint %tmp ) ; [#uses=1]
16 ret int %tmp
13 %result = tail call int %memcmp( sbyte* %tmp8, sbyte* %tmp4, uint %tmp ) ; [#uses=1]
14 ret int %result
1715 }
1816
1917 declare int %memcmp(sbyte*, sbyte*, uint)
99 %tmp24.i = load int* null ; [#uses=1]
1010 %tmp13.i12.i = tail call double %ldexp( double 0.000000e+00, int 0 ) ; [#uses=1]
1111 %tmp13.i13.i = cast double %tmp13.i12.i to float ; [#uses=1]
12 %tmp11.i = load int* null ; [#uses=1]
13 %tmp11.i = cast int %tmp11.i to uint ; int> [#uses=1]
12 %tmp11.s = load int* null ; <int> [#uses=1]
13 %tmp11.i = cast int %tmp11.s to uint ; [#uses=1]
1414 %n.i = cast int %tmp24.i to uint ; [#uses=1]
1515 %tmp13.i7 = mul uint %tmp11.i, %n.i ; [#uses=1]
1616 %tmp.i8 = tail call sbyte* %calloc( uint %tmp13.i7, uint 4 ) ; [#uses=0]
44
55 implementation ; Functions:
66
7 void %foo(int %N) {
7 void %foo(int %N.in) {
88 entry:
9 %N = cast int %N to uint ; [#uses=1]
9 %N = cast int %N.in to uint ; [#uses=1]
1010 br label %cond_true
1111
1212 cond_true: ; preds = %cond_true, %entry
33
44 %A = internal global [16 x [16 x int]] zeroinitializer, align 32
55
6 void %test(int %row, int %N) {
6 void %test(int %row, int %N.in) {
77 entry:
8 %N = cast int %N to uint
9 %tmp5 = setgt int %N, 0
8 %N = cast int %N.in to uint
9 %tmp5 = setgt int %N.in, 0
1010 br bool %tmp5, label %cond_true, label %return
1111
1212 cond_true:
0 ; An integer truncation to bool should be done with an and instruction to make
11 ; sure only the LSBit survives. Test that this is the case both for a returned
22 ; value and as the operand of a branch.
3 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=x86 &&
4 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=x86 | grep '\(and\)\|\(test.*\$1\)' | wc -l | grep 6
5 bool %test1(int %X) {
6 %Y = trunc int %X to bool
3 ; RUN: llvm-as < %s | llc -march=x86 &&
4 ; RUN: llvm-as < %s | llc -march=x86 | grep '\(and\)\|\(test.*\$1\)' | \
5 ; RUN: wc -l | grep 6
6
7 define bool @zext %test1(i32 %X) {
8 %Y = trunc i32 %X to bool
79 ret bool %Y
810 }
911
10 bool %test2(int %val, int %mask) {
12 define bool %test2(i32 %val, i32 %mask) {
1113 entry:
12 %mask = trunc int %mask to ubyte
13 %shifted = ashr int %val, ubyte %mask
14 %anded = and int %shifted, 1
15 %trunced = trunc int %anded to bool
14 %mask = trunc i32 %mask to i8
15 %shifted = ashr i32 %val, i8 %mask
16 %anded = and i32 %shifted, 1
17 %trunced = trunc i32 %anded to bool
1618 br bool %trunced, label %ret_true, label %ret_false
1719 ret_true:
1820 ret bool true
2022 ret bool false
2123 }
2224
23 int %test3(sbyte* %ptr) {
24 %val = load sbyte* %ptr
25 %tmp = trunc sbyte %val to bool ; % [#uses=1]
25 define i32 %test3(i8* %ptr) {
26 %val = load i8* %ptr
27 %tmp = trunc i8 %val to bool
2628 br bool %tmp, label %cond_true, label %cond_false
2729 cond_true:
28 ret int 21
30 ret i32 21
2931 cond_false:
30 ret int 42
32 ret i32 42
3133 }
3234
33 int %test4(sbyte* %ptr) {
34 %tmp = ptrtoint sbyte* %ptr to bool
35 define i32 %test4(i8* %ptr) {
36 %tmp = ptrtoint i8* %ptr to bool
3537 br bool %tmp, label %cond_true, label %cond_false
3638 cond_true:
37 ret int 21
39 ret i32 21
3840 cond_false:
39 ret int 42
41 ret i32 42
4042 }
4143
42 int %test5(float %f) {
44 define i32 %test5(float %f) {
4345 %tmp = fptoui float %f to bool
4446 br bool %tmp, label %cond_true, label %cond_false
4547 cond_true:
46 ret int 21
48 ret i32 21
4749 cond_false:
48 ret int 42
50 ret i32 42
4951 }
5052
51 int %test6(double %d) {
53 define i32 %test6(double %d) {
5254 %tmp = fptosi double %d to bool
5355 br bool %tmp, label %cond_true, label %cond_false
5456 cond_true:
55 ret int 21
57 ret i32 21
5658 cond_false:
57 ret int 42
59 ret i32 42
5860 }
61
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -instcombine | \
1 ; RUN: llc -march=x86 -mcpu=yonah &&
1 ; RUN: llc -march=x86 -mcpu=yonah &&
22 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl -instcombine | \
3 ; RUN: llc -march=x86 -mcpu=yonah | not grep sub.*esp
3 ; RUN: llc -march=x86 -mcpu=yonah | not grep sub.*esp
44
55 ; This checks that various insert/extract idiom work without going to the
66 ; stack.
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33 int %main() {
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33 target endian = little
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33 ; Testcase distilled from 256.bzip2.
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33 ; This testcase failed to work because two variable sized allocas confused the
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33 ; This testcase exposes a bug in the local register allocator where it runs out
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33 %.LC0 = internal global [12 x sbyte] c"Hello World\00"
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33 implementation
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33
None ; RUN: llvm-as -f %s -o %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc
11 ; RUN: lli %t.bc > /dev/null
22
33 ; test return instructions
44
5 void %test() { ret void }
6 sbyte %test() { ret sbyte 1 }
7 ubyte %test() { ret ubyte 1 }
8 short %test() { ret short -1 }
9 ushort %test() { ret ushort 65535 }
5 void %test1() { ret void }
6 sbyte %test2() { ret sbyte 1 }
7 ubyte %test3() { ret ubyte 1 }
8 short %test4() { ret short -1 }
9 ushort %test5() { ret ushort 65535 }
1010 int %main() { ret int 0 }
11 uint %test() { ret uint 4 }
12 long %test() { ret long 0 }
13 ulong %test() { ret ulong 0 }
14 float %test() { ret float 1.0 }
15 double %test() { ret double 2.0 }
11 uint %test6() { ret uint 4 }
12 long %test7() { ret long 0 }
13 ulong %test8() { ret ulong 0 }
14 float %test9() { ret float 1.0 }
15 double %test10() { ret double 2.0 }
55 %shamt = add ubyte 0, 1
66
77 ; Left shifts...
8 %t1 = shl int 1, ubyte %shamt
9 %t2 = shl int 1, ubyte 4
8 %t1.s = shl int 1, ubyte %shamt
9 %t2.s = shl int 1, ubyte 4
1010
1111 %t1 = shl uint 1, ubyte %shamt
1212 %t2 = shl uint 1, ubyte 5
1313
1414 ;%t1 = shl long 1, ubyte %shamt
15 %t2 = shl long 1, ubyte 4
15 %t2.s = shl long 1, ubyte 4
1616
1717 ;%t1 = shl ulong 1, ubyte %shamt
1818 %t2 = shl ulong 1, ubyte 5
1919
2020 ; Right shifts...
21 %tr1 = shr int 1, ubyte %shamt
22 %tr2 = shr int 1, ubyte 4
21 %tr1.s = shr int 1, ubyte %shamt
22 %tr2.s = shr int 1, ubyte 4
2323
2424 %tr1 = shr uint 1, ubyte %shamt
2525 %tr2 = shr uint 1, ubyte 5
2626
2727 ;%tr1 = shr long 1, ubyte %shamt
28 %tr1 = shr long 1, ubyte 4
29 %tr2 = shr long 1, ubyte %shamt
30 %tr3 = shl long 1, ubyte 4
31 %tr4 = shl long 1, ubyte %shamt
28 %tr1.l = shr long 1, ubyte 4
29 %tr2.l = shr long 1, ubyte %shamt
30 %tr3.l = shl long 1, ubyte 4
31 %tr4.l = shl long 1, ubyte %shamt
3232
3333 ;%t1 = shr ulong 1, ubyte %shamt
34 %tr1 = shr ulong 1, ubyte 5
35 %tr2 = shr ulong 1, ubyte %shamt
36 %tr3 = shl ulong 1, ubyte 5
37 %tr4 = shl ulong 1, ubyte %shamt
34 %tr1.u = shr ulong 1, ubyte 5
35 %tr2.u = shr ulong 1, ubyte %shamt
36 %tr3.u = shl ulong 1, ubyte 5
37 %tr4.u = shl ulong 1, ubyte %shamt
3838 ret int 0
3939 }
None ; RUN: llvm-as < %s > %t.bc
0 ; RUN: llvm-upgrade < %s | llvm-as > %t.bc
11 ; RUN: echo | llvm-as > %t.tmp.bc
22 ; RUN: llvm-link %t.tmp.bc %t.bc
33
0 ; This fails linking when it is linked with an empty file as the first object file
11
22 ; RUN: llvm-as > %t1.bc < /dev/null
3 ; RUN: llvm-as < %s > %t2.bc
3 ; RUN: llvm-upgrade < %s | llvm-as > %t2.bc
44 ; RUN: llvm-link %t[12].bc
55
66 %work = global int (int, int)* %zip
0 ; This fails linking when it is linked with an empty file as the first object file
11
22 ; RUN: llvm-as > %t.LinkTest.bc < /dev/null
3 ; RUN: llvm-as < %s > %t.bc
3 ; RUN: llvm-upgrade < %s | llvm-as > %t.bc
44 ; RUN: llvm-link %t.LinkTest.bc %t.bc
55
66 %work = global int 4
0 ; This one fails because the LLVM runtime is allowing two null pointers of
11 ; the same type to be created!
22
3 ; RUN: echo "%T = type int" | llvm-as > %t.2.bc
3 ; RUN: echo "%T = type int" | llvm-upgrade | llvm-as > %t.2.bc
44 ; RUN: llvm-upgrade < %s | llvm-as -f > %t.1.bc
55 ; RUN: llvm-link %t.[12].bc
66
0 ; This one fails because the LLVM runtime is allowing two null pointers of
11 ; the same type to be created!
22
3 ; RUN: echo "%S = type { %T*} %T = type opaque" | llvm-as > %t.2.bc
4 ; RUN: llvm-as < %s > %t.1.bc
3 ; RUN: echo "%S = type { %T*} %T = type opaque" | llvm-upgrade | llvm-as > %t.2.bc
4 ; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
55 ; RUN: llvm-link %t.[12].bc
66
77 %S = type { %T* }
None ; RUN: echo "%T = type opaque" | llvm-as > %t.2.bc
1 ; RUN: llvm-as < %s > %t.1.bc
0 ; RUN: echo "%T = type opaque" | llvm-upgrade | llvm-as > %t.2.bc
1 ; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
22 ; RUN: llvm-link %t.[12].bc
33
44 %T = type opaque
None ; RUN: echo "%T = type int" | llvm-as > %t.1.bc
1 ; RUN: llvm-as < %s > %t.2.bc
0 ; RUN: echo "%T = type int" | llvm-upgrade | llvm-as > %t.1.bc
1 ; RUN: llvm-upgrade < %s | llvm-as > %t.2.bc
22 ; RUN: llvm-link %t.[12].bc
33
44 %T = type opaque
0
1 ; RUN: llvm-as < %s > %t.out1.bc
2 ; RUN: echo "%S = type { int, int* }" | llvm-as > %t.out2.bc
1 ; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
2 ; RUN: echo "%S = type { int, int* }" | llvm-upgrade | llvm-as > %t.out2.bc
33 ; RUN: llvm-link %t.out[12].bc
44
55 %T = type opaque
None ; RUN: llvm-as < %s > %t.out1.bc
1 ; RUN: echo "%S = external global { int, opaque* } declare void %F(opaque*)" | llvm-as > %t.out2.bc
0 ; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
1 ; RUN: echo "%S = external global { int, opaque* } declare void %F(opaque*)" | llvm-upgrade | llvm-as > %t.out2.bc
22 ; RUN: llvm-link %t.out[12].bc | llvm-dis | not grep opaque
33
44 ; After linking this testcase, there should be no opaque types left. The two
0 ; It's a bad idea to go recursively traipsing through types without a safety
11 ; net.
22
3 ; RUN: llvm-as < %s > %t.out1.bc
4 ; RUN: echo "%S = type { %S*, int* }" | llvm-as > %t.out2.bc
3 ; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
4 ; RUN: echo "%S = type { %S*, int* }" | llvm-upgrade | llvm-as > %t.out2.bc
55 ; RUN: llvm-link %t.out[12].bc
66
77 %S = type { %S*, opaque* }
None ; RUN: llvm-as < %s > %t.out1.bc
1 ; RUN: echo "%S = type [8 x int] external global %S " | llvm-as > %t.out2.bc
0 ; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
1 ; RUN: echo "%S = type [8 x int] external global %S " | llvm-upgrade | llvm-as > %t.out2.bc
22 ; RUN: llvm-link %t.out[12].bc | llvm-dis | grep %S | grep '{'
33
44 %S = type { int }
0 ; The linker should merge link-once globals into strong external globals,
11 ; just like it does for weak symbols!
22
3 ; RUN: echo "%X = global int 7" | llvm-as > %t.2.bc
4 ; RUN: llvm-as < %s > %t.1.bc
3 ; RUN: echo "%X = global int 7" | llvm-upgrade | llvm-as > %t.2.bc
4 ; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
55 ; RUN: llvm-link %t.[12].bc
66
77 %X = linkonce global int 7
None ; RUN: llvm-as < %s > %t.out2.bc
1 ; RUN: echo "%me = global int* null" | llvm-as > %t.out1.bc
0 ; RUN: llvm-upgrade < %s | llvm-as > %t.out2.bc
1 ; RUN: echo "%me = global int* null" | llvm-upgrade | llvm-as > %t.out1.bc
22 ; RUN: llvm-link %t.out[12].bc -o /dev/null -f
33
44 %me = weak global int * null
0 ; Test that a prototype can be marked const, and the definition is allowed
11 ; to be nonconst.
22
3 ; RUN: echo "%X = external constant int" | llvm-as > %t.2.bc
4 ; RUN: llvm-as < %s > %t.1.bc
5 ; RUN: llvm-link %t.[12].bc | llvm-dis | grep 'global int 7'
3 ; RUN: echo "%X = external constant int" | llvm-upgrade | llvm-as > %t.2.bc
4 ; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
5 ; RUN: llvm-link %t.[12].bc | llvm-dis | grep 'global i32 7'
66
77 %X = global int 7
0 ; Test that a prototype can be marked const, and the definition is allowed
11 ; to be nonconst.
22
3 ; RUN: echo "%X = global int 7" | llvm-as > %t.2.bc
4 ; RUN: llvm-as < %s > %t.1.bc
5 ; RUN: llvm-link %t.[12].bc | llvm-dis | grep 'global int 7'
3 ; RUN: echo "%X = global int 7" | llvm-upgrade | llvm-as > %t.2.bc
4 ; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
5 ; RUN: llvm-link %t.[12].bc | llvm-dis | grep 'global i32 7'
66
77 %X = external constant int
None ; RUN: echo "%G = appending global [0 x int] zeroinitializer" | llvm-as > %t.out2.bc
1 ; RUN: llvm-as < %s > %t.out1.bc
0 ; RUN: echo "%G = appending global [0 x int] zeroinitializer" | llvm-upgrade | llvm-as > %t.out2.bc
1 ; RUN: llvm-upgrade < %s | llvm-as > %t.out1.bc
22 ; RUN: llvm-link %t.out[12].bc | llvm-dis | grep '%G ='
33
44 ; When linked, the globals should be merged, and the result should still
None ; RUN: llvm-as %s -f -o %s.bc ; llvm-link -f -o %s.linked %s.bc
0 ; RUN: llvm-upgrade < %s | llvm-as -f -o %s.bc ; llvm-link -f -o %s.linked %s.bc
11
22 target endian = big
33 target pointersize = 32
0 ; The linker should choose the largest alignment when linking.
11
2 ; RUN: echo "%X = global int 7, align 8" | llvm-as > %t.2.bc
3 ; RUN: llvm-as < %s > %t.1.bc
2 ; RUN: echo "%X = global int 7, align 8" | llvm-upgrade | llvm-as > %t.2.bc
3 ; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
44 ; RUN: llvm-link %t.[12].bc | llvm-dis | grep 'align 8'
55
66 %X = weak global int 7, align 4
0 ; Test that appending linkage works correctly when arrays are the same size.
11
2 ; RUN: echo "%X = appending global [1x int] [int 8]" | llvm-as > %t.2.bc
3 ; RUN: llvm-as < %s > %t.1.bc
2 ; RUN: echo "%X = appending global [1x int] [int 8]" | llvm-upgrade | llvm-as > %t.2.bc
3 ; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
44 ; RUN: llvm-link %t.[12].bc | llvm-dis | grep 7 | grep 8
55
66 %X = appending global [1 x int] [int 7]
0 ; Test that appending linkage works correctly when arrays are the same size.
11
2 ; RUN: echo "%X = constant [1x int] [int 8]" | llvm-as > %t.2.bc
3 ; RUN: llvm-upgrade %s | llvm-as > %t.1.bc
2 ; RUN: echo "%X = constant [1x int] [int 8]" | llvm-upgrade | llvm-as > %t.2.bc
3 ; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
44 ; RUN: llvm-link %t.[12].bc | llvm-dis | grep constant
55
66 %X = uninitialized global [1 x int]
0 ; Test that appending linkage works correctly when arrays are the same size.
11
2 ; RUN: echo "%X = external global [1x int]" | llvm-as > %t.2.bc
3 ; RUN: llvm-upgrade %s | llvm-as > %t.1.bc
2 ; RUN: echo "%X = external global [1x int]" | llvm-upgrade | llvm-as > %t.2.bc
3 ; RUN: llvm-upgrade %s -o - | llvm-as > %t.1.bc
44 ; RUN: llvm-link %t.[12].bc | llvm-dis | grep constant
55
66 %X = constant [1 x int] [ int 12 ]
0 ; Test that appending linkage works correctly when arrays are the same size.
11
2 ; RUN: echo "%X = external constant [1x int]" | llvm-as > %t.2.bc
2 ; RUN: echo "%X = external constant [1x int]" | llvm-upgrade | llvm-as > %t.2.bc
33 ; RUN: llvm-upgrade %s | llvm-as > %t.1.bc
44 ; RUN: llvm-link %t.[12].bc | llvm-dis | grep constant
55
0 ; This fails because the linker renames the non-opaque type not the opaque
11 ; one...
22
3 ; RUN: echo "%X = linkonce global int 8" | llvm-as > %t.2.bc
4 ; RUN: llvm-as < %s > %t.1.bc
3 ; RUN: echo "%X = linkonce global int 8" | llvm-upgrade | llvm-as > %t.2.bc
4 ; RUN: llvm-upgrade < %s | llvm-as > %t.1.bc
55 ; RUN: llvm-link %t.[12].bc | llvm-dis
66
77 %X = linkonce global int 7
None ; RUN: llvm-as < %s > %t.bc
1 ; RUN: llvm-as < `dirname %s`/testlink1.ll > %t2.bc
0 ; RUN: llvm-upgrade < %s | llvm-as > %t.bc
1 ; RUN: llvm-upgrade < `dirname %s`/testlink1.ll | llvm-as > %t2.bc
22 ; RUN: llvm-link %t.bc %t.bc %t2.bc -o %t1.bc -f
3 ; RUN: llvm-dis < %t1.bc |grep "kallsyms_names = extern_weak" &&
4 ; RUN: llvm-dis < %t1.bc |grep "MyVar = external global int" &&
5 ; RUN: llvm-dis < %t1.bc |grep "Inte = global int"
3 ; RUN: llvm-dis < %t1.bc | grep "kallsyms_names = extern_weak" &&
4 ; RUN: llvm-dis < %t1.bc | grep "MyVar = external global i32" &&
5 ; RUN: llvm-dis < %t1.bc | grep "Inte = global i32"
66
77 %kallsyms_names = extern_weak global [0 x ubyte]
88 %MyVar = extern_weak global int
None ; RUN: llvm-upgrade < %s | llvm-as | opt -argpromotion | llvm-dis | grep 'load int\* %A'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -argpromotion | llvm-dis | grep 'load i32\* %A'
11
22 implementation
33
None ; RUN: llvm-upgrade < %s | llvm-as | opt -constprop | llvm-dis | grep 'uint -1' &&
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -constprop | llvm-dis | grep 'i32 -1' &&
11 ; RUN: llvm-upgrade < %s | llvm-as | opt -constprop | llvm-dis | not grep zeroinitializer
22
33 < 4 x uint> %test() {
None ; RUN: llvm-upgrade < %s | llvm-as | opt -constprop | llvm-dis | grep 'ret int -1' &&
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -constprop | llvm-dis | grep 'ret uint 1'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -constprop | llvm-dis | grep 'ret i32 -1' &&
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -constprop | llvm-dis | grep 'ret i32 1'
22
33 int %test1() {
44 %A = sext bool true to int
None ; RUN: llvm-as < %s | llvm-dis &&
1 ; RUN: llvm-as < %s | llvm-dis | grep 0x36A0000000000000
0 ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis &&
1 ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis | grep 0x36A0000000000000
22
33 %A = global float bitcast (int 1 to float)
None ; RUN: llvm-upgrade < %s | llvm-as | opt -constprop | llvm-dis | grep -F 'ret int* null' | wc -l | grep 2
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -constprop | llvm-dis | grep -F 'ret i32* null' | wc -l | grep 2
11 int* %test1() {
22 %X = cast float 0.0 to int*
33 ret int* %X
None ; RUN: llvm-upgrade < %s | llvm-as | opt -dse | llvm-dis | grep 'store int 1234567'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -dse | llvm-dis | grep 'store i32 1234567'
11
22 ; Do not delete stores that are only partially killed.
33
754754 %tmp.i = load %struct.TType** %DP_TTable ; <%struct.TType*> [#uses=1]
755755 %tmp.i7.b = load bool* %TTSize.b ; [#uses=1]
756756 %tmp1.i = select bool %tmp.i7.b, uint 60000000, uint 0 ; [#uses=1]
757 %tmp.i = getelementptr %struct.TType* %tmp.i, int 0, uint 0 ; [#uses=1]
758 call void %llvm.memset.i32( sbyte* %tmp.i, ubyte 0, uint %tmp1.i, uint 4 )
757 %tmp.i.sb = getelementptr %struct.TType* %tmp.i, int 0, uint 0 ; [#uses=1]
758 call void %llvm.memset.i32( sbyte* %tmp.i.sb, ubyte 0, uint %tmp1.i, uint 4 )
759759 %tmp2.i = load %struct.TType** %AS_TTable ; <%struct.TType*> [#uses=1]
760760 %tmp3.i8.b = load bool* %TTSize.b ; [#uses=1]
761761 %tmp4.i = select bool %tmp3.i8.b, uint 60000000, uint 0 ; [#uses=1]
762762 %tmp2.i = getelementptr %struct.TType* %tmp2.i, int 0, uint 0 ; [#uses=1]
763763 call void %llvm.memset.i32( sbyte* %tmp2.i, ubyte 0, uint %tmp4.i, uint 4 )
764 %tmp.i = load %struct.QTType** %QS_TTable ; <%struct.QTType*> [#uses=1]
764 %tmp.i.QTT = load %struct.QTType** %QS_TTable ; <%struct.QTType*> [#uses=1]
765765 %tmp5.i9.b = load bool* %TTSize.b ; [#uses=1]
766766 %tmp6.i10 = select bool %tmp5.i9.b, uint 48000000, uint 0 ; [#uses=1]
767 %tmp7.i = getelementptr %struct.QTType* %tmp.i, int 0, uint 0 ; [#uses=1]
767 %tmp7.i = getelementptr %struct.QTType* %tmp.i.QTT, int 0, uint 0 ; [#uses=1]
768768 call void %llvm.memset.i32( sbyte* %tmp7.i, ubyte 0, uint %tmp6.i10, uint 4 )
769 %tmp.i = load %struct.ECacheType** %ECache ; <%struct.ECacheType*> [#uses=1]
769 %tmp.i.ECache = load %struct.ECacheType** %ECache ; <%struct.ECacheType*> [#uses=1]
770770 %tmp.i14.b = load bool* %ECacheSize.b ; [#uses=1]
771771 %tmp1.i16 = select bool %tmp.i14.b, uint 12000000, uint 0 ; [#uses=1]
772 %tmp.i17 = cast %struct.ECacheType* %tmp.i to sbyte* ; [#uses=1]
772 %tmp.i17 = cast %struct.ECacheType* %tmp.i.ECache to sbyte* ; [#uses=1]
773773 call void %llvm.memset.i32( sbyte* %tmp.i17, ubyte 0, uint %tmp1.i16, uint 4 )
774774 call void %llvm.memset.i32( sbyte* cast ([300 x int]* %rootlosers to sbyte*), ubyte 0, uint 1200, uint 4 )
775775 %tmp234.b = load bool* %is_pondering.b ; [#uses=1]
799799 %tmp1.b.i = load bool* %PBSize.b ; [#uses=1]
800800 %tmp1.i1 = select bool %tmp1.b.i, uint 200000, uint 0 ; [#uses=1]
801801 %tmp.i2 = call sbyte* %calloc( uint %tmp1.i1, uint 44 ) ; [#uses=1]
802 %tmp.i = cast sbyte* %tmp.i2 to ubyte* ; [#uses=1]
803 store ubyte* %tmp.i, ubyte** %membuff
802 %tmp.i.ub = cast sbyte* %tmp.i2 to ubyte* ; [#uses=1]
803 store ubyte* %tmp.i.ub, ubyte** %membuff
804804 %tmp2.i3 = call sbyte* %calloc( uint 1, uint 44 ) ; [#uses=3]
805805 %tmp2.i = cast sbyte* %tmp2.i3 to %struct.node_t* ; <%struct.node_t*> [#uses=6]
806 %tmp.i = getelementptr [512 x %struct.move_s]* null, int 0, int 0 ; <%struct.move_s*> [#uses=3]
807 call fastcc void %gen( %struct.move_s* %tmp.i )
806 %tmp.i.move_s = getelementptr [512 x %struct.move_s]* null, int 0, int 0 ; <%struct.move_s*> [#uses=3]
807 call fastcc void %gen( %struct.move_s* %tmp.i.move_s )
808808 %tmp3.i4 = load int* %numb_moves ; [#uses=4]
809809 %tmp3.i5 = cast int %tmp3.i4 to uint ; [#uses=0]
810810 store bool false, bool* %alllosers.b
849849 cond_true43.i: ; preds = %cond_false12.i.i, %cond_true4.i.i
850850 %tmp21.0.ph.i = phi int [ %tmp217.i, %cond_true4.i.i ], [ %tmp2120.i, %cond_false12.i.i ] ; [#uses=1]
851851 %i.0.0.i = cast uint 0 to int ; [#uses=2]
852 call fastcc void %make( %struct.move_s* %tmp.i, int %i.0.0.i )
853 %tmp27.i = call fastcc uint %check_legal( %struct.move_s* %tmp.i, int %i.0.0.i, int %tmp21.0.ph.i ) ; [#uses=1]
852 call fastcc void %make( %struct.move_s* %tmp.i.move_s, int %i.0.0.i )
853 %tmp27.i = call fastcc uint %check_legal( %struct.move_s* %tmp.i.move_s, int %i.0.0.i, int %tmp21.0.ph.i ) ; [#uses=1]
854854 %tmp.i6 = seteq uint %tmp27.i, 0 ; [#uses=0]
855855 ret void
856856
None ; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep 'ret int 152'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep 'ret i32 152'
11
22 int %main() {
33 entry:
None ; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep 'ret int 27'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep 'ret i32 27'
11
22 ; Make sure to compute the right exit value based on negative strides.
33 ; PR726
None ; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -instcombine | llvm-dis | grep 'store int 0'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -instcombine | llvm-dis | grep 'store i32 0'
11 ; Test that -indvars can reduce variable stride IVs. If it can reduce variable
22 ; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without
33 ; cycles, allowing the tmp.21 subtraction to be eliminated.
1818 br label %no_exit
1919
2020 no_exit: ; preds = %no_exit, %no_exit.preheader
21 %iv. = phi uint [ 0, %no_exit.preheader ], [ %iv..inc, %no_exit ] ; [#uses=1]
21 %iv.ui = phi uint [ 0, %no_exit.preheader ], [ %iv..inc.ui, %no_exit ] ; [#uses=1]
2222 %iv. = phi int [ %tmp.5, %no_exit.preheader ], [ %iv..inc, %no_exit ] ; [#uses=2]
2323 %m.0.0 = phi int [ %tmp.5, %no_exit.preheader ], [ %tmp.24, %no_exit ] ; [#uses=2]
2424 store int 2, int* %tmp.16
2626 store int %tmp.21, int* %data
2727 %tmp.24 = add int %m.0.0, %tmp.9 ; [#uses=1]
2828 %iv..inc = add int %tmp.9, %iv. ; [#uses=1]
29 %iv..inc = add uint %iv., 1 ; [#uses=2]
30 %iv..inc1 = cast uint %iv..inc to int ; [#uses=1]
29 %iv..inc.ui = add uint %iv.ui, 1 ; [#uses=2]
30 %iv..inc1 = cast uint %iv..inc.ui to int ; [#uses=1]
3131 %tmp.12 = setlt int %iv..inc1, %tmp.2 ; [#uses=1]
3232 br bool %tmp.12, label %no_exit, label %return.loopexit
3333
None ; RUN: llvm-upgrade < %s | llvm-as | opt -inline | llvm-dis | grep 'ret int 1'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -inline | llvm-dis | grep 'ret i32 1'
11 ; ModuleID = 'short.opt.bc'
22
33 implementation ; Functions:
99
1010 int %mem_mono_copy_mono(%struct.gx_device* %dev, ubyte* %base, int %sourcex, int %raster, int %x, int %y, int %w, int %h, uint %zero, uint %one) {
1111 entry:
12 %raster = cast int %raster to uint ; [#uses=3]
12 %raster.ui = cast int %raster to uint ; [#uses=3]
1313 %tmp = seteq uint %one, %zero ; [#uses=1]
1414 br bool %tmp, label %cond_true, label %cond_next
1515
145145 %optr.3.2 = phi ubyte* [ %tmp232, %cond_true249 ], [ %dest.1.0, %cond_true249.preheader ] ; [#uses=1]
146146 %bptr.3.2 = phi ubyte* [ %tmp226, %cond_true249 ], [ %line.1.0, %cond_true249.preheader ] ; [#uses=1]
147147 %tmp. = add int %tmp109, %w ; [#uses=1]
148 %indvar = cast uint %indvar to int ; [#uses=1]
149148 %tmp.58 = mul int %indvar, -8 ; [#uses=1]
150149 %tmp.57 = add int %tmp., -16 ; [#uses=1]
151150 %tmp246.2 = add int %tmp.58, %tmp.57 ; [#uses=1]
235234 %dest.1.0.us = phi ubyte* [ %tmp286.us, %cond_next280.us ], [ %tmp100, %cond_true295.preheader.split.us ] ; [#uses=3]
236235 %dest_line.1.0.us = phi ubyte** [ %tmp282.us, %cond_next280.us ], [ %tmp96, %cond_true295.preheader.split.us ] ; [#uses=1]
237236 %tmp.89 = sub uint 0, %indvar86 ; [#uses=1]
238 %tmp.89 = cast uint %tmp.89 to int ; [#uses=1]
239237 %tmp292.0.us = add int %tmp.89, %tmp29222 ; [#uses=1]
240 %tmp.91 = mul uint %indvar86, %raster ; [#uses=1]
241 %tmp.91 = cast uint %tmp.91 to int ; <int> [#uses=1]
238 %tmp.91 = mul uint %indvar86, %raster.ui ; int> [#uses=1]
242239 %tmp104.sum101 = add int %tmp102, %tmp.91 ; [#uses=1]
243240 %line.1.0.us = getelementptr ubyte* %base, int %tmp104.sum101 ; [#uses=2]
244241 %tmp.us = load ubyte* %line.1.0.us ; [#uses=1]
312309 %dest.1.0 = phi ubyte* [ %tmp286, %cond_next280 ], [ %tmp100, %cond_true295.preheader.split ] ; [#uses=4]
313310 %dest_line.1.0 = phi ubyte** [ %tmp282, %cond_next280 ], [ %tmp96, %cond_true295.preheader.split ] ; [#uses=1]
314311 %tmp.63 = sub uint 0, %indvar60 ; [#uses=1]
315 %tmp.63 = cast uint %tmp.63 to int ; [#uses=1]
316312 %tmp292.0 = add int %tmp.63, %tmp29222 ; [#uses=1]
317 %tmp.65 = mul uint %indvar60, %raster ; [#uses=1]
318 %tmp.65 = cast uint %tmp.65 to int ; <int> [#uses=1]
313 %tmp.65 = mul uint %indvar60, %raster.ui ; int> [#uses=1]
319314 %tmp104.sum97 = add int %tmp102, %tmp.65 ; [#uses=1]
320315 %line.1.0 = getelementptr ubyte* %base, int %tmp104.sum97 ; [#uses=3]
321316 %tmp = load ubyte* %line.1.0 ; [#uses=1]
385380 %optr309.3.0 = phi ubyte* [ %optr309.3, %cond_true398 ], [ %optr309.353, %cond_true398.preheader ] ; [#uses=2]
386381 %optr309.3.in.0 = add uint %indvar66, %optr309.3.in51 ; [#uses=1]
387382 %tmp.70 = add int %tmp109, %w ; [#uses=1]
388 %indvar66 = cast uint %indvar66 to int ; [#uses=1]
389383 %tmp.72 = mul int %indvar66, -8 ; [#uses=1]
390384 %tmp.71 = add int %tmp.70, -8 ; [#uses=1]
391385 %count308.3.0 = add int %tmp.72, %tmp.71 ; [#uses=1]
439433 %tmp416 = load ubyte* %tmp410 ; [#uses=1]
440434 %tmp416 = cast ubyte %tmp416 to uint ; [#uses=1]
441435 %tmp418 = shr uint %tmp416, ubyte %tmp319 ; [#uses=1]
442 %tmp418 = cast uint %tmp418 to int ; [#uses=1]
443436 %tmp420 = add int %tmp418, %tmp408 ; [#uses=1]
444437 br label %cond_next422
445438
478471 %tmp354 = and uint %iftmp.37.0, %mask.1.1 ; [#uses=1]
479472 %tmp361 = sub int %w, %tmp110 ; [#uses=2]
480473 %tmp39755 = setgt int %tmp361, 7 ; [#uses=1]
481 %iftmp.35.0 = cast uint %iftmp.35.0 to int ; [#uses=1]
482474 %tmp426 = cast uint %rmask.0.1 to ubyte ; [#uses=1]
483475 %tmp426not = xor ubyte %tmp426, 255 ; [#uses=1]
484476 %tmp428 = or ubyte %tmp347, %tmp426not ; [#uses=1]
491483 %dest.3.0 = phi ubyte* [ %tmp448, %cond_next442 ], [ %tmp100, %cond_true457.preheader ] ; [#uses=3]
492484 %dest_line.3.0 = phi ubyte** [ %tmp444, %cond_next442 ], [ %tmp96, %cond_true457.preheader ] ; [#uses=1]
493485 %tmp.77 = sub uint 0, %indvar74 ; [#uses=1]
494 %tmp.77 = cast uint %tmp.77 to int ; [#uses=1]
495486 %tmp454.0 = add int %tmp.77, %tmp45438 ; [#uses=1]
496 %tmp.79 = mul uint %indvar74, %raster ; [#uses=1]
497 %tmp.79 = cast uint %tmp.79 to int ; <int> [#uses=1]
487 %tmp.79 = mul uint %indvar74, %raster.ui ; int> [#uses=1]
498488 %tmp104.sum = add int %tmp102, %tmp.79 ; [#uses=1]
499489 %line.3.0 = getelementptr ubyte* %base, int %tmp104.sum ; [#uses=3]
500490 %tmp318 = load ubyte* %line.3.0 ; [#uses=2]
88 entry:
99 %tmp = getelementptr { long, long, long, long }* null, int 0, uint 3
1010 %tmp = load long* %tmp ; [#uses=1]
11 %tmp8 = load ulong* null ; [#uses=1]
12 %tmp8 = cast ulong %tmp8 to long ; <long> [#uses=1]
11 %tmp8.ui = load ulong* null ; long> [#uses=1]
12 %tmp8 = cast ulong %tmp8.ui to long ; [#uses=1]
1313 %tmp9 = and long %tmp8, %tmp ; [#uses=1]
1414 %sext = cast long %tmp9 to int ; [#uses=1]
1515 %tmp27.i = cast int %sext to long ; [#uses=1]
11 ; PR913
22
33 int %test(int* %tmp1) {
4 %tmp = load int* %tmp1 ; [#uses=1]
5 %tmp = cast int %tmp to uint ; [#uses=1]
6 %tmp2 = shr uint %tmp, ubyte 5 ; [#uses=1]
7 %tmp2 = cast uint %tmp2 to int ; [#uses=1]
4 %tmp.i = load int* %tmp1 ; [#uses=1]
5 %tmp = cast int %tmp.i to uint ; [#uses=1]
6 %tmp2.ui = shr uint %tmp, ubyte 5 ; [#uses=1]
7 %tmp2 = cast uint %tmp2.ui to int ; [#uses=1]
88 %tmp3 = and int %tmp2, 1 ; [#uses=1]
99 %tmp3 = cast int %tmp3 to bool ; [#uses=1]
1010 %tmp34 = cast bool %tmp3 to int ; [#uses=1]
0 ; The optimizer should be able to remove cast operation here.
1 ; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | not grep 'sext.*int'
1 ; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | not grep 'sext.*i32'
22
33 bool %eq_signed_to_small_unsigned(sbyte %SB) {
44 %Y = cast sbyte %SB to uint ; [#uses=1]
0 ; This test case is reduced from llvmAsmParser.cpp
11 ; The optimizer should not remove the cast here.
2 ; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | grep 'sext.*int'
2 ; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | grep 'sext.*i32'
33
44 bool %test(short %X) {
55 %A = cast short %X to uint
None ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep 'ret int %A'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep 'ret i32 %A'
11
22 int %test(int %A) {
33 %X = or bool false, false
0 ; Test some floating point casting cases
11 ; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | notcast
22 ; RUN: llvm-upgrade %s -o - | llvm-as | opt -instcombine | llvm-dis | \
3 ; RUN: grep 'ret [us]byte \(-1\)\|\(255\)'
3 ; RUN: grep 'ret i8 \(-1\)\|\(255\)'
44
5 sbyte %test() {
5 sbyte %test1() {
66 %x = fptoui float 255.0 to sbyte
77 ret sbyte %x
88 }
99
10 ubyte %test() {
10 ubyte %test2() {
1111 %x = fptosi float -1.0 to ubyte
1212 ret ubyte %x
1313 }
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine -disable-output &&
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep 'lshr int' | wc -l | grep 2 &&
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep 'lshr i32' | wc -l | grep 2 &&
22 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | not grep ashr
33
44 int %test1(int %X, ubyte %A) {
0 ; This test makes sure that these instructions are properly eliminated.
11 ;
22
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep -v 'sub int %Cok, %Bok' | not grep sub
3 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep -v 'sub i32 %Cok, %Bok' | not grep sub
44
55 implementation
66
None ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep 'and int %Y, 8'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | grep 'and i32 %Y, 8'
11
22 int %test1(ubyte %X) {
33 %Y = cast ubyte %X to int
None ; RUN: llvm-upgrade < %s | llvm-as | opt -lcssa | llvm-dis | grep "X3.lcssa = phi int" &&
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -lcssa | llvm-dis | grep "%X4 = add int 3, %X3.lcssa"
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -lcssa | llvm-dis | grep "X3.lcssa = phi i32" &&
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -lcssa | llvm-dis | grep "%X4 = add i32 3, %X3.lcssa"
22
33 void %lcssa(bool %S2) {
44 entry:
2222 loop.exit:
2323 %X4 = add int 3, %X3
2424 ret void
25 }
25 }
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -licm | llvm-dis
11
2 void "testfunc"(int %i) {
2 void "testfunc"(int %i.s) {
33
44 br label %Loop
55
66 Loop:
77 %j = phi uint [0, %0], [%Next, %Loop]
8 %i = cast int %i to uint
8 %i = cast int %i.s to uint
99 %i2 = mul uint %i, 17
1010 %Next = add uint %j, %i2
1111 %cond = seteq uint %Next, 0
0 ; Test that LICM works when there is not a loop-preheader
11 ; RUN: llvm-upgrade < %s | llvm-as | opt -licm | llvm-dis
22
3 void "testfunc"(int %i, bool %ifcond) {
3 void "testfunc"(int %i.s, bool %ifcond) {
44 br bool %ifcond, label %Then, label %Else
55 Then:
66 br label %Loop
99
1010 Loop:
1111 %j = phi uint [0, %Then], [12, %Else], [%Next, %Loop]
12 %i = cast int %i to uint
12 %i = cast int %i.s to uint
1313 %i2 = mul uint %i, 17
1414 %Next = add uint %j, %i2
1515 %cond = seteq uint %Next, 0
2424 br label %no_exit.1
2525
2626 no_exit.1: ; preds = %cond_continue, %no_exit.1.outer
27 %indvar = phi uint [ 0, %no_exit.1.outer ], [ %indvar.next, %cond_continue ] ; [#uses=2]
28 %indvar = cast uint %indvar to int ; [#uses=1]
27 %indvar.ui = phi uint [ 0, %no_exit.1.outer ], [ %indvar.next, %cond_continue ] ; [#uses=2]
28 %indvar = cast uint %indvar.ui to int ; [#uses=1]
2929 %j.1.2 = add int %indvar, %j.1.2.ph ; [#uses=2]
3030 %tmp.11 = add int %j.1.2, %tmp.9 ; [#uses=1]
3131 %tmp.12 = cast int %tmp.11 to ubyte ; [#uses=1]
4242
4343 cond_continue: ; preds = %no_exit.1
4444 %tmp.519 = setlt int %inc.1, %C ; [#uses=1]
45 %indvar.next = add uint %indvar, 1 ; [#uses=1]
45 %indvar.next = add uint %indvar.ui, 1 ; [#uses=1]
4646 br bool %tmp.519, label %no_exit.1, label %loopexit.1
4747
4848 loopexit.1: ; preds = %cond_continue, %cond_true, %loopentry.1
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | grep mul | wc -l | grep 1
11 ; LSR should not make two copies of the Q*L expression in the preheader!
22
3 sbyte %test(sbyte* %A, sbyte* %B, int %L, int %Q, int %N) {
3 sbyte %test(sbyte* %A, sbyte* %B, int %L, int %Q, int %N.s) {
44 entry:
55 %tmp.6 = mul int %Q, %L ; [#uses=1]
6 %N = cast int %N to uint ; [#uses=1]
6 %N = cast int %N.s to uint ; [#uses=1]
77 br label %no_exit
88
99 no_exit: ; preds = %no_exit, %no_exit.preheader
10 %indvar = phi uint [ 0, %entry], [ %indvar.next, %no_exit ] ; [#uses=2]
10 %indvar.ui = phi uint [ 0, %entry], [ %indvar.next, %no_exit ] ; [#uses=2]
1111 %Sum.0.0 = phi sbyte [ 0, %entry], [ %tmp.21, %no_exit ] ; [#uses=1]
12 %indvar = cast uint %indvar to int ; [#uses=1]
13 %N_addr.0.0 = sub int %N, %indvar ; [#uses=1]
12 %indvar = cast uint %indvar.ui to int ; [#uses=1]
13 %N_addr.0.0 = sub int %N.s, %indvar ; [#uses=1]
1414 %tmp.8 = add int %N_addr.0.0, %tmp.6 ; [#uses=2]
1515 %tmp.9 = getelementptr sbyte* %A, int %tmp.8 ; [#uses=1]
1616 %tmp.10 = load sbyte* %tmp.9 ; [#uses=1]
1818 %tmp.18 = load sbyte* %tmp.17 ; [#uses=1]
1919 %tmp.19 = sub sbyte %tmp.10, %tmp.18 ; [#uses=1]
2020 %tmp.21 = add sbyte %tmp.19, %Sum.0.0 ; [#uses=2]
21 %indvar.next = add uint %indvar, 1 ; [#uses=2]
21 %indvar.next = add uint %indvar.ui, 1 ; [#uses=2]
2222 %exitcond = seteq uint %indvar.next, %N ; [#uses=1]
2323 br bool %exitcond, label %loopexit, label %no_exit
2424
None ; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | grep 'add uint %iv.*inc, 1'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -loop-reduce | llvm-dis | grep 'add i32 %iv.*inc, 1'
11 ;
22 ; Make sure that the use of the IV outside of the loop (the store) uses the
33 ; post incremented value of the IV, not the preincremented value. This
1212 br label %no_exit.2
1313
1414 no_exit.2: ; preds = %no_exit.2, %then.0
15 %indvar630 = phi uint [ 0, %then.0 ], [ %indvar.next631, %no_exit.2 ] ; [#uses=3]
16 %indvar630 = cast uint %indvar630 to int ; [#uses=1]
17 %tmp.38 = getelementptr [700 x int]* %nbeaux_.0__558, int 0, uint %indvar630 ; [#uses=1]
15 %indvar630.ui = phi uint [ 0, %then.0 ], [ %indvar.next631, %no_exit.2 ] ; [#uses=3]
16 %indvar630 = cast uint %indvar630.ui to int ; [#uses=1]
17 %tmp.38 = getelementptr [700 x int]* %nbeaux_.0__558, int 0, uint %indvar630.ui ; [#uses=1]
1818 store int 0, int* %tmp.38
1919 %inc.2 = add int %indvar630, 2 ; [#uses=2]
2020 %tmp.34 = call bool %pred(int %indvar630)
21 %indvar.next631 = add uint %indvar630, 1 ; [#uses=1]
21 %indvar.next631 = add uint %indvar630.ui, 1 ; [#uses=1]
2222 br bool %tmp.34, label %no_exit.2, label %loopexit.2.loopexit
2323
2424 loopexit.2.loopexit: ; preds = %no_exit.2
1616
1717 implementation ; Functions:
1818
19 void %foo(int %k, int %i) {
19 void %foo(int %k, int %i.s) {
2020 entry:
21 %i = cast int %i to uint ; [#uses=2]
22 %k_addr.012 = shl int %i, ubyte 1 ; [#uses=1]
21 %i = cast int %i.s to uint ; [#uses=2]
22 %k_addr.012 = shl int %i.s, ubyte 1 ; [#uses=1]
2323 %tmp14 = setgt int %k_addr.012, 8192 ; [#uses=1]
2424 br bool %tmp14, label %return, label %bb.preheader
2525
3434 %k_addr.0.0 = cast uint %tmp.16 to int ; [#uses=1]
3535 %tmp = getelementptr [8193 x sbyte]* %flags2, int 0, uint %tmp.16 ; [#uses=1]
3636 store sbyte 0, sbyte* %tmp
37 %k_addr.0 = add int %k_addr.0.0, %i ; [#uses=1]
37 %k_addr.0 = add int %k_addr.0.0, %i.s ; [#uses=1]
3838 %tmp = setgt int %k_addr.0, 8192 ; [#uses=1]
3939 %indvar.next = add uint %indvar, 1 ; [#uses=1]
4040 br bool %tmp, label %return.loopexit, label %bb
14201420 no_exit.53: ; preds = %else.166, %else.168, %then.360, %no_exit.53.outer
14211421 %file.2.3.3.ph = phi int [ 0, %no_exit.53.outer ], [ %inc.551688, %then.360 ], [ %inc.551701, %else.168 ], [ %file.2.3.3.ph, %else.166 ] ; [#uses=2]
14221422 %nempty.5.3.ph = phi int [ 0, %no_exit.53.outer ], [ %nempty.5.3, %then.360 ], [ %nempty.5.3, %else.168 ], [ %nempty.5.3.ph, %else.166 ] ; [#uses=2]
1423 %indvar2053 = phi uint [ 0, %no_exit.53.outer ], [ 0, %then.360 ], [ 0, %else.168 ], [ %indvar.next2054, %else.166 ] ; [#uses=2]
1424 %indvar2053 = cast uint %indvar2053 to int ; <int> [#uses=2]
1423 %indvar2053.ui = phi uint [ 0, %no_exit.53.outer ], [ 0, %then.360 ], [ 0, %else.168 ], [ %indvar.next2054, %else.166 ] ; int> [#uses=2]
1424 %indvar2053 = cast uint %indvar2053.ui to int ; [#uses=2]
14251425 %file.2.3.3 = add int %indvar2053, %file.2.3.3.ph ; [#uses=4]
14261426 %nempty.5.3 = add int %indvar2053, %nempty.5.3.ph ; [#uses=3]
14271427 %tmp.4749 = add int %file.2.3.3, %tmp.4747 ; [#uses=1]
14711471 else.166: ; preds = %no_exit.53
14721472 %inc.55 = add int %file.2.3.3, 1 ; [#uses=1]
14731473 %tmp.47421705 = setlt int %inc.55, 8 ; [#uses=1]
1474 %indvar.next2054 = add uint %indvar2053, 1 ; [#uses=1]
1474 %indvar.next2054 = add uint %indvar2053.ui, 1 ; [#uses=1]
14751475 br bool %tmp.47421705, label %no_exit.53, label %loopexit.56
14761476
14771477 loopexit.56: ; preds = %else.166, %else.168, %then.360
1515 br label %cond_true
1616
1717 cond_true: ; preds = %return.i, %cond_true.outer
18 %indvar = phi uint [ 0, %cond_true.outer ], [ %indvar.next, %return.i ] ; [#uses=2]
19 %indvar = cast uint %indvar to int ; [#uses=1]
18 %indvar.ui = phi uint [ 0, %cond_true.outer ], [ %indvar.next, %return.i ] ; [#uses=2]
19 %indvar = cast uint %indvar.ui to int ; [#uses=1]
2020 %i.0.0 = add int %indvar, %i.0.0.ph ; [#uses=3]
2121 %savedstack = call sbyte* %llvm.stacksave( ) ; [#uses=2]
2222 %tmp.i = seteq int %i.0.0, 0 ; [#uses=1]
3737 return.i: ; preds = %cond_true
3838 call void %llvm.stackrestore( sbyte* %savedstack )
3939 %tmp21 = setgt int %tmp5, 9999 ; [#uses=1]
40 %indvar.next = add uint %indvar, 1 ; [#uses=1]
40 %indvar.next = add uint %indvar.ui, 1 ; [#uses=1]
4141 br bool %tmp21, label %bb8, label %cond_true
4242
4343 bb8: ; preds = %return.i, %cond_true.i
None ; RUN: llvm-upgrade < %s | llvm-as | opt -reassociate -instcombine | llvm-dis | grep 'ret int 0'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -reassociate -instcombine | llvm-dis | grep 'ret i32 0'
11
22 int %f(int %a0, int %a1, int %a2, int %a3, int %a4) {
33 %tmp.2 = add int %a4, %a3 ; [#uses=1]
0 ; With shl->mul reassociation, we can see that this is (shl A, 9) * A
11 ;
2 ; RUN: llvm-upgrade < %s | llvm-as | opt -reassociate -instcombine | llvm-dis | grep 'shl .*, ubyte 9'
2 ; RUN: llvm-upgrade < %s | llvm-as | opt -reassociate -instcombine | llvm-dis | grep 'shl .*, i8 9'
33
44 int %test(int %A, int %B) {
55 %X = shl int %A, ubyte 5
None ; RUN: llvm-upgrade < %s | llvm-as | opt -sccp | llvm-dis | grep 'ret int 1'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -sccp | llvm-dis | grep 'ret i32 1'
11
22 ; This function definitely returns 1, even if we don't know the direction
33 ; of the branch.
104104
105105 void %gldLLVMVecPointRender(%struct.GLDContextRec* %ctx) {
106106 entry:
107 %tmp = getelementptr %struct.GLDContextRec* %ctx, int 0, uint 22 ; [#uses=1]
108 %tmp = load uint* %tmp ; [#uses=3]
107 %tmp.uip = getelementptr %struct.GLDContextRec* %ctx, int 0, uint 22 ; [#uses=1]
108 %tmp = load uint* %tmp.uip ; [#uses=3]
109109 %tmp91 = lshr uint %tmp, ubyte 5 ; [#uses=1]
110110 %tmp92 = trunc uint %tmp91 to bool ; [#uses=1]
111111 br bool %tmp92, label %cond_true93, label %cond_next116
None ; RUN: llvm-upgrade < %s | llvm-as | opt -ipsccp | llvm-dis | grep -v 'ret int 17' | grep -v 'ret int undef' | not grep ret
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -ipsccp | llvm-dis | grep -v 'ret i32 17' | grep -v 'ret i32 undef' | not grep ret
11
22 implementation
33
None ; RUN: llvm-upgrade < %s | llvm-as | opt -ipsccp | llvm-dis | grep -v 'ret int 0' | grep -v 'ret int undef' | not grep ret
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -ipsccp | llvm-dis | grep -v 'ret i32 0' | grep -v 'ret i32 undef' | not grep ret
11
22 implementation
33
None ; RUN: llvm-upgrade < %s | llvm-as | opt -sccp | llvm-dis | grep 'ret int 0'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -sccp | llvm-dis | grep 'ret i32 0'
11
22 ; Test that SCCP has basic knowledge of when and/or nuke overdefined values.
33
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis &&
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | grep -F 'alloca [2 x <4 x int>]'
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | grep -F 'alloca [2 x <4 x i32>]'
22
33 int %func(<4 x float> %v0, <4 x float> %v1) {
44 %vsiidx = alloca [2 x <4 x int>], align 16 ; <[2 x <4 x int>]*> [#uses=3]
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | not grep alloca &&
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | grep 'bitcast.*float.*int'
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | grep 'bitcast.*float.*i32'
22
33 int %test(float %X) {
44 %X_addr = alloca float
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | not grep alloca &&
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | grep 'ret sbyte'
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -scalarrepl | llvm-dis | grep 'ret i8'
22
33 ; PR892
44
412412 cond_next225: ; preds = %invcont222, %cond_true217, %invcont213
413413 %toPage.1 = phi int [ %tmp223, %invcont222 ], [ %tmp214, %cond_true217 ], [ %tmp214, %invcont213 ] ; [#uses=2]
414414 %fromPage.1 = phi int [ 1, %invcont222 ], [ %tmp211, %cond_true217 ], [ %tmp211, %invcont213 ] ; [#uses=2]
415 %tmp = invoke uint %_ZNK8QPrinter9pageOrderEv( %struct.QPrinter* %printer )
415 %tmp.page = invoke uint %_ZNK8QPrinter9pageOrderEv( %struct.QPrinter* %printer )
416416 to label %invcont227 unwind label %cleanup329 ; [#uses=1]
417417
418418 invcont227: ; preds = %cond_next225
419 %tmp228 = seteq uint %tmp, 1 ; [#uses=1]
419 %tmp228 = seteq uint %tmp.page, 1 ; [#uses=1]
420420 br bool %tmp228, label %cond_true230, label %cond_next234
421421
422422 cond_true230: ; preds = %invcont227
5555
5656 bb: ; preds = %bb33
5757 %tmp = load %struct.FILE** %f_addr ; <%struct.FILE*> [#uses=1]
58 %tmp = call int %_IO_getc( %struct.FILE* %tmp ) ; [#uses=1]
58 %tmp.r = call int %_IO_getc( %struct.FILE* %tmp ) ; [#uses=1]
5959 %tmp6 = call int %tolower( int %tmp ) ; [#uses=1]
6060 %tmp6 = trunc int %tmp6 to sbyte ; [#uses=1]
6161 store sbyte %tmp6, sbyte* %c
0 ; Test that the ExitInMainOptimization pass works correctly
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | grep -c 'ret int 3' | grep 1
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -simplify-libcalls | llvm-dis | grep -c 'ret i32 3' | grep 1
22
33 declare void %exit(int)
44 declare void %exitonly(int)
None ; RUN: llvm-upgrade < %s | llvm-as | opt -tailcallelim | llvm-dis | grep 'call int %foo'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -tailcallelim | llvm-dis | grep 'call i32 %foo'
11
22 declare void %bar(int*)
33 int %foo(uint %N) {
None ; RUN: llvm-upgrade < %s | llvm-as | opt -tailcallelim | llvm-dis | %prcontext alloca 1 | grep 'int %foo'
0 ; RUN: llvm-upgrade < %s | llvm-as | opt -tailcallelim | llvm-dis | %prcontext alloca 1 | grep 'i32 %foo'
11
22 declare void %bar(int*)
33 int %foo() {