diff options
Diffstat (limited to 'test/Transforms/SimplifyCFG')
60 files changed, 1230 insertions, 443 deletions
diff --git a/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll b/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll index fbfb100274f6..0626ea178e5c 100644 --- a/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll +++ b/test/Transforms/SimplifyCFG/2003-08-17-FoldSwitch-dbg.ll @@ -9,7 +9,7 @@ @.str = internal constant [4 x i8] c"a.c\00", section "llvm.metadata" ; <[4 x i8]*> [#uses=1] @.str1 = internal constant [6 x i8] c"/tmp/\00", section "llvm.metadata" ; <[6 x i8]*> [#uses=1] @.str2 = internal constant [55 x i8] c"4.2.1 (Based on Apple Inc. build 5636) (LLVM build 00)\00", section "llvm.metadata" ; <[55 x i8]*> [#uses=1] -@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] +@llvm.dbg.compile_unit = internal constant %llvm.dbg.compile_unit.type { i32 458769, { }* bitcast (%llvm.dbg.anchor.type* @llvm.dbg.compile_units to { }*), i32 1, i8* getelementptr ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr ([6 x i8], [6 x i8]* @.str1, i32 0, i32 0), i8* getelementptr ([55 x i8], [55 x i8]* @.str2, i32 0, i32 0), i1 true, i1 false, i8* null }, section "llvm.metadata" ; <%llvm.dbg.compile_unit.type*> [#uses=1] declare void @llvm.dbg.stoppoint(i32, i32, { }*) nounwind diff --git a/test/Transforms/SimplifyCFG/2005-06-16-PHICrash.ll b/test/Transforms/SimplifyCFG/2005-06-16-PHICrash.ll index 90be6803a5c3..8fd1fae34503 100644 --- a/test/Transforms/SimplifyCFG/2005-06-16-PHICrash.ll +++ b/test/Transforms/SimplifyCFG/2005-06-16-PHICrash.ll @@ -30,7 +30,7 @@ endif.0: ; preds = %loopentry.0 %tmp.14 = sext i8 %tmp.1 to i32 ; <i32> [#uses=1] %tmp.16 = zext i8 %l_88173906 to i32 ; <i32> [#uses=1] %tmp.17 = icmp sgt i32 %tmp.14, %tmp.16 ; <i1> [#uses=1] - %tmp.19 = load i32* @g_59182229 ; <i32> [#uses=2] + %tmp.19 = load i32, i32* @g_59182229 ; <i32> [#uses=2] br i1 %tmp.17, label %cond_true, label %cond_false cond_true: ; preds = %endif.0 %tmp.20 = icmp ne i32 %tmp.19, 1 ; <i1> [#uses=1] @@ -53,7 +53,7 @@ loopentry.1: ; preds = %endif.3, %else.2 %tmp.29 = icmp sgt i32 %i.1.1, 99 ; <i1> [#uses=1] br i1 %tmp.29, label %endif.2, label %no_exit.1 no_exit.1: ; preds = %loopentry.1 - %tmp.30 = load i32* @g_38098584 ; <i32> [#uses=1] + %tmp.30 = load i32, i32* @g_38098584 ; <i32> [#uses=1] %tmp.31 = icmp eq i32 %tmp.30, 0 ; <i1> [#uses=1] br i1 %tmp.31, label %else.3, label %then.3 then.3: ; preds = %no_exit.1 diff --git a/test/Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll b/test/Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll index c30bfa1379c7..c45986749ab0 100644 --- a/test/Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll +++ b/test/Transforms/SimplifyCFG/2005-08-01-PHIUpdateFail.ll @@ -58,7 +58,7 @@ then.2.i: ; preds = %endif.1.i, %then.1.i getfree.exit: ; preds = %endif.1.i, %then.1.i ret void endif.1: ; preds = %read_min.exit - %tmp.27.i = getelementptr i32* null, i32 0 ; <i32*> [#uses=0] + %tmp.27.i = getelementptr i32, i32* null, i32 0 ; <i32*> [#uses=0] br i1 false, label %loopexit.0.i15, label %no_exit.0.i14 no_exit.0.i14: ; preds = %endif.1 ret void diff --git a/test/Transforms/SimplifyCFG/2005-12-03-IncorrectPHIFold.ll b/test/Transforms/SimplifyCFG/2005-12-03-IncorrectPHIFold.ll index 907261bd438a..2606e08da9a2 100644 --- a/test/Transforms/SimplifyCFG/2005-12-03-IncorrectPHIFold.ll +++ b/test/Transforms/SimplifyCFG/2005-12-03-IncorrectPHIFold.ll @@ -36,8 +36,8 @@ entry: %guess = alloca %struct.anon* ; <%struct.anon**> [#uses=7] %guess1 = alloca %struct.anon* ; <%struct.anon**> [#uses=7] %point5 = alloca %struct.anon* ; <%struct.anon**> [#uses=3] - %tmp = load %struct.anon** %num ; <%struct.anon*> [#uses=1] - %tmp1 = load %struct.anon** @_zero_ ; <%struct.anon*> [#uses=1] + %tmp = load %struct.anon*, %struct.anon** %num ; <%struct.anon*> [#uses=1] + %tmp1 = load %struct.anon*, %struct.anon** @_zero_ ; <%struct.anon*> [#uses=1] %tmp.upgrd.1 = call i32 @bc_compare( %struct.anon* %tmp, %struct.anon* %tmp1 ) ; <i32> [#uses=2] %tmp.upgrd.2 = icmp slt i32 %tmp.upgrd.1, 0 ; <i1> [#uses=1] br i1 %tmp.upgrd.2, label %cond_true, label %cond_false @@ -48,26 +48,26 @@ cond_false: ; preds = %entry br i1 %tmp5, label %cond_true6, label %cond_next13 cond_true6: ; preds = %cond_false call void @free_num( %struct.anon** %num ) - %tmp8 = load %struct.anon** @_zero_ ; <%struct.anon*> [#uses=1] + %tmp8 = load %struct.anon*, %struct.anon** @_zero_ ; <%struct.anon*> [#uses=1] %tmp9 = call %struct.anon* @copy_num( %struct.anon* %tmp8 ) ; <%struct.anon*> [#uses=1] store %struct.anon* %tmp9, %struct.anon** %num ret i32 1 cond_next13: ; preds = %cond_false - %tmp15 = load %struct.anon** %num ; <%struct.anon*> [#uses=1] - %tmp16 = load %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] + %tmp15 = load %struct.anon*, %struct.anon** %num ; <%struct.anon*> [#uses=1] + %tmp16 = load %struct.anon*, %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] %tmp17 = call i32 @bc_compare( %struct.anon* %tmp15, %struct.anon* %tmp16 ) ; <i32> [#uses=2] %tmp19 = icmp eq i32 %tmp17, 0 ; <i1> [#uses=1] br i1 %tmp19, label %cond_true20, label %cond_next27 cond_true20: ; preds = %cond_next13 call void @free_num( %struct.anon** %num ) - %tmp22 = load %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] + %tmp22 = load %struct.anon*, %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] %tmp23 = call %struct.anon* @copy_num( %struct.anon* %tmp22 ) ; <%struct.anon*> [#uses=1] store %struct.anon* %tmp23, %struct.anon** %num ret i32 1 cond_next27: ; preds = %cond_next13 - %tmp29 = load %struct.anon** %num ; <%struct.anon*> [#uses=1] - %tmp30 = getelementptr %struct.anon* %tmp29, i32 0, i32 2 ; <i32*> [#uses=1] - %tmp31 = load i32* %tmp30 ; <i32> [#uses=2] + %tmp29 = load %struct.anon*, %struct.anon** %num ; <%struct.anon*> [#uses=1] + %tmp30 = getelementptr %struct.anon, %struct.anon* %tmp29, i32 0, i32 2 ; <i32*> [#uses=1] + %tmp31 = load i32, i32* %tmp30 ; <i32> [#uses=2] %tmp33 = icmp sge i32 %tmp31, %scale ; <i1> [#uses=1] %max = select i1 %tmp33, i32 %tmp31, i32 %scale ; <i32> [#uses=4] %tmp35 = add i32 %max, 2 ; <i32> [#uses=0] @@ -75,29 +75,29 @@ cond_next27: ; preds = %cond_next13 call void @init_num( %struct.anon** %guess1 ) %tmp36 = call %struct.anon* @new_num( i32 1, i32 1 ) ; <%struct.anon*> [#uses=2] store %struct.anon* %tmp36, %struct.anon** %point5 - %tmp.upgrd.3 = getelementptr %struct.anon* %tmp36, i32 0, i32 4, i32 1 ; <i8*> [#uses=1] + %tmp.upgrd.3 = getelementptr %struct.anon, %struct.anon* %tmp36, i32 0, i32 4, i32 1 ; <i8*> [#uses=1] store i8 5, i8* %tmp.upgrd.3 %tmp39 = icmp slt i32 %tmp17, 0 ; <i1> [#uses=1] br i1 %tmp39, label %cond_true40, label %cond_false43 cond_true40: ; preds = %cond_next27 - %tmp41 = load %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] + %tmp41 = load %struct.anon*, %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] %tmp42 = call %struct.anon* @copy_num( %struct.anon* %tmp41 ) ; <%struct.anon*> [#uses=1] store %struct.anon* %tmp42, %struct.anon** %guess br label %bb80.outer cond_false43: ; preds = %cond_next27 call void @int2num( %struct.anon** %guess, i32 10 ) - %tmp45 = load %struct.anon** %num ; <%struct.anon*> [#uses=1] - %tmp46 = getelementptr %struct.anon* %tmp45, i32 0, i32 1 ; <i32*> [#uses=1] - %tmp47 = load i32* %tmp46 ; <i32> [#uses=1] + %tmp45 = load %struct.anon*, %struct.anon** %num ; <%struct.anon*> [#uses=1] + %tmp46 = getelementptr %struct.anon, %struct.anon* %tmp45, i32 0, i32 1 ; <i32*> [#uses=1] + %tmp47 = load i32, i32* %tmp46 ; <i32> [#uses=1] call void @int2num( %struct.anon** %guess1, i32 %tmp47 ) - %tmp48 = load %struct.anon** %guess1 ; <%struct.anon*> [#uses=1] - %tmp49 = load %struct.anon** %point5 ; <%struct.anon*> [#uses=1] + %tmp48 = load %struct.anon*, %struct.anon** %guess1 ; <%struct.anon*> [#uses=1] + %tmp49 = load %struct.anon*, %struct.anon** %point5 ; <%struct.anon*> [#uses=1] call void @bc_multiply( %struct.anon* %tmp48, %struct.anon* %tmp49, %struct.anon** %guess1, i32 %max ) - %tmp51 = load %struct.anon** %guess1 ; <%struct.anon*> [#uses=1] - %tmp52 = getelementptr %struct.anon* %tmp51, i32 0, i32 2 ; <i32*> [#uses=1] + %tmp51 = load %struct.anon*, %struct.anon** %guess1 ; <%struct.anon*> [#uses=1] + %tmp52 = getelementptr %struct.anon, %struct.anon* %tmp51, i32 0, i32 2 ; <i32*> [#uses=1] store i32 0, i32* %tmp52 - %tmp53 = load %struct.anon** %guess ; <%struct.anon*> [#uses=1] - %tmp54 = load %struct.anon** %guess1 ; <%struct.anon*> [#uses=1] + %tmp53 = load %struct.anon*, %struct.anon** %guess ; <%struct.anon*> [#uses=1] + %tmp54 = load %struct.anon*, %struct.anon** %guess1 ; <%struct.anon*> [#uses=1] call void @bc_raise( %struct.anon* %tmp53, %struct.anon* %tmp54, %struct.anon** %guess, i32 %max ) br label %bb80.outer bb80.outer: ; preds = %cond_true83, %cond_false43, %cond_true40 @@ -113,8 +113,8 @@ cond_true83: ; preds = %bb80 ; CHECK: bb86 bb86: ; preds = %bb80 call void @free_num( %struct.anon** %num ) - %tmp88 = load %struct.anon** %guess ; <%struct.anon*> [#uses=1] - %tmp89 = load %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] + %tmp88 = load %struct.anon*, %struct.anon** %guess ; <%struct.anon*> [#uses=1] + %tmp89 = load %struct.anon*, %struct.anon** @_one_ ; <%struct.anon*> [#uses=1] %tmp92 = call i32 @bc_divide( %struct.anon* %tmp88, %struct.anon* %tmp89, %struct.anon** %num, i32 %max ) ; <i32> [#uses=0] call void @free_num( %struct.anon** %guess ) call void @free_num( %struct.anon** %guess1 ) diff --git a/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll b/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll index 70fbddfe33b4..0820e9c9825f 100644 --- a/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll +++ b/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll @@ -34,7 +34,7 @@ target triple = "powerpc-apple-darwin8" define void @fold_builtin_classify() { entry: - %tmp63 = load i32* null ; <i32> [#uses=1] + %tmp63 = load i32, i32* null ; <i32> [#uses=1] switch i32 %tmp63, label %bb276 [ i32 414, label %bb145 i32 417, label %bb @@ -42,54 +42,54 @@ entry: bb: ; preds = %entry ret void bb145: ; preds = %entry - %tmp146 = load %struct.tree_node** null ; <%struct.tree_node*> [#uses=1] - %tmp148 = getelementptr %struct.tree_node* %tmp146, i32 0, i32 0, i32 0, i32 1 ; <%struct.tree_node**> [#uses=1] - %tmp149 = load %struct.tree_node** %tmp148 ; <%struct.tree_node*> [#uses=1] + %tmp146 = load %struct.tree_node*, %struct.tree_node** null ; <%struct.tree_node*> [#uses=1] + %tmp148 = getelementptr %struct.tree_node, %struct.tree_node* %tmp146, i32 0, i32 0, i32 0, i32 1 ; <%struct.tree_node**> [#uses=1] + %tmp149 = load %struct.tree_node*, %struct.tree_node** %tmp148 ; <%struct.tree_node*> [#uses=1] %tmp150 = bitcast %struct.tree_node* %tmp149 to %struct.tree_type* ; <%struct.tree_type*> [#uses=1] - %tmp151 = getelementptr %struct.tree_type* %tmp150, i32 0, i32 6 ; <i16*> [#uses=1] + %tmp151 = getelementptr %struct.tree_type, %struct.tree_type* %tmp150, i32 0, i32 6 ; <i16*> [#uses=1] %tmp151.upgrd.1 = bitcast i16* %tmp151 to i32* ; <i32*> [#uses=1] - %tmp152 = load i32* %tmp151.upgrd.1 ; <i32> [#uses=1] + %tmp152 = load i32, i32* %tmp151.upgrd.1 ; <i32> [#uses=1] %tmp154 = lshr i32 %tmp152, 16 ; <i32> [#uses=1] %tmp154.mask = and i32 %tmp154, 127 ; <i32> [#uses=1] %gep.upgrd.2 = zext i32 %tmp154.mask to i64 ; <i64> [#uses=1] - %tmp155 = getelementptr [35 x i8]* @mode_class, i32 0, i64 %gep.upgrd.2 ; <i8*> [#uses=1] - %tmp156 = load i8* %tmp155 ; <i8> [#uses=1] + %tmp155 = getelementptr [35 x i8], [35 x i8]* @mode_class, i32 0, i64 %gep.upgrd.2 ; <i8*> [#uses=1] + %tmp156 = load i8, i8* %tmp155 ; <i8> [#uses=1] %tmp157 = icmp eq i8 %tmp156, 4 ; <i1> [#uses=1] br i1 %tmp157, label %cond_next241, label %cond_true158 cond_true158: ; preds = %bb145 - %tmp172 = load %struct.tree_node** null ; <%struct.tree_node*> [#uses=1] - %tmp174 = getelementptr %struct.tree_node* %tmp172, i32 0, i32 0, i32 0, i32 1 ; <%struct.tree_node**> [#uses=1] - %tmp175 = load %struct.tree_node** %tmp174 ; <%struct.tree_node*> [#uses=1] + %tmp172 = load %struct.tree_node*, %struct.tree_node** null ; <%struct.tree_node*> [#uses=1] + %tmp174 = getelementptr %struct.tree_node, %struct.tree_node* %tmp172, i32 0, i32 0, i32 0, i32 1 ; <%struct.tree_node**> [#uses=1] + %tmp175 = load %struct.tree_node*, %struct.tree_node** %tmp174 ; <%struct.tree_node*> [#uses=1] %tmp176 = bitcast %struct.tree_node* %tmp175 to %struct.tree_type* ; <%struct.tree_type*> [#uses=1] - %tmp177 = getelementptr %struct.tree_type* %tmp176, i32 0, i32 6 ; <i16*> [#uses=1] + %tmp177 = getelementptr %struct.tree_type, %struct.tree_type* %tmp176, i32 0, i32 6 ; <i16*> [#uses=1] %tmp177.upgrd.3 = bitcast i16* %tmp177 to i32* ; <i32*> [#uses=1] - %tmp178 = load i32* %tmp177.upgrd.3 ; <i32> [#uses=1] + %tmp178 = load i32, i32* %tmp177.upgrd.3 ; <i32> [#uses=1] %tmp180 = lshr i32 %tmp178, 16 ; <i32> [#uses=1] %tmp180.mask = and i32 %tmp180, 127 ; <i32> [#uses=1] %gep.upgrd.4 = zext i32 %tmp180.mask to i64 ; <i64> [#uses=1] - %tmp181 = getelementptr [35 x i8]* @mode_class, i32 0, i64 %gep.upgrd.4 ; <i8*> [#uses=1] - %tmp182 = load i8* %tmp181 ; <i8> [#uses=1] + %tmp181 = getelementptr [35 x i8], [35 x i8]* @mode_class, i32 0, i64 %gep.upgrd.4 ; <i8*> [#uses=1] + %tmp182 = load i8, i8* %tmp181 ; <i8> [#uses=1] %tmp183 = icmp eq i8 %tmp182, 8 ; <i1> [#uses=1] br i1 %tmp183, label %cond_next241, label %cond_true184 cond_true184: ; preds = %cond_true158 - %tmp185 = load %struct.tree_node** null ; <%struct.tree_node*> [#uses=1] - %tmp187 = getelementptr %struct.tree_node* %tmp185, i32 0, i32 0, i32 0, i32 1 ; <%struct.tree_node**> [#uses=1] - %tmp188 = load %struct.tree_node** %tmp187 ; <%struct.tree_node*> [#uses=1] + %tmp185 = load %struct.tree_node*, %struct.tree_node** null ; <%struct.tree_node*> [#uses=1] + %tmp187 = getelementptr %struct.tree_node, %struct.tree_node* %tmp185, i32 0, i32 0, i32 0, i32 1 ; <%struct.tree_node**> [#uses=1] + %tmp188 = load %struct.tree_node*, %struct.tree_node** %tmp187 ; <%struct.tree_node*> [#uses=1] %tmp189 = bitcast %struct.tree_node* %tmp188 to %struct.tree_type* ; <%struct.tree_type*> [#uses=1] - %tmp190 = getelementptr %struct.tree_type* %tmp189, i32 0, i32 6 ; <i16*> [#uses=1] + %tmp190 = getelementptr %struct.tree_type, %struct.tree_type* %tmp189, i32 0, i32 6 ; <i16*> [#uses=1] %tmp190.upgrd.5 = bitcast i16* %tmp190 to i32* ; <i32*> [#uses=1] - %tmp191 = load i32* %tmp190.upgrd.5 ; <i32> [#uses=1] + %tmp191 = load i32, i32* %tmp190.upgrd.5 ; <i32> [#uses=1] %tmp193 = lshr i32 %tmp191, 16 ; <i32> [#uses=1] %tmp193.mask = and i32 %tmp193, 127 ; <i32> [#uses=1] %gep.upgrd.6 = zext i32 %tmp193.mask to i64 ; <i64> [#uses=1] - %tmp194 = getelementptr [35 x i8]* @mode_class, i32 0, i64 %gep.upgrd.6 ; <i8*> [#uses=1] - %tmp195 = load i8* %tmp194 ; <i8> [#uses=1] + %tmp194 = getelementptr [35 x i8], [35 x i8]* @mode_class, i32 0, i64 %gep.upgrd.6 ; <i8*> [#uses=1] + %tmp195 = load i8, i8* %tmp194 ; <i8> [#uses=1] %tmp196 = icmp eq i8 %tmp195, 4 ; <i1> [#uses=1] br i1 %tmp196, label %cond_next241, label %cond_true197 cond_true197: ; preds = %cond_true184 ret void cond_next241: ; preds = %cond_true184, %cond_true158, %bb145 - %tmp245 = load i32* null ; <i32> [#uses=0] + %tmp245 = load i32, i32* null ; <i32> [#uses=0] ret void bb276: ; preds = %entry ret void diff --git a/test/Transforms/SimplifyCFG/2006-12-08-Ptr-ICmp-Branch.ll b/test/Transforms/SimplifyCFG/2006-12-08-Ptr-ICmp-Branch.ll index af865ce7fac0..dcf241255d85 100644 --- a/test/Transforms/SimplifyCFG/2006-12-08-Ptr-ICmp-Branch.ll +++ b/test/Transforms/SimplifyCFG/2006-12-08-Ptr-ICmp-Branch.ll @@ -45,42 +45,42 @@ entry: store %struct.trie_s* %t, %struct.trie_s** %t_addr store %struct.FILE* %f, %struct.FILE** %f_addr store i32 0, i32* %wstate - %tmp = getelementptr %struct.charsequence* %cs, i64 0, i32 0 ; <i8**> [#uses=1] - %tmp1 = getelementptr %struct.charsequence* @C.0.2294, i64 0, i32 0 ; <i8**> [#uses=1] - %tmp.upgrd.5 = load i8** %tmp1 ; <i8*> [#uses=1] + %tmp = getelementptr %struct.charsequence, %struct.charsequence* %cs, i64 0, i32 0 ; <i8**> [#uses=1] + %tmp1 = getelementptr %struct.charsequence, %struct.charsequence* @C.0.2294, i64 0, i32 0 ; <i8**> [#uses=1] + %tmp.upgrd.5 = load i8*, i8** %tmp1 ; <i8*> [#uses=1] store i8* %tmp.upgrd.5, i8** %tmp - %tmp.upgrd.6 = getelementptr %struct.charsequence* %cs, i64 0, i32 1 ; <i32*> [#uses=1] - %tmp2 = getelementptr %struct.charsequence* @C.0.2294, i64 0, i32 1 ; <i32*> [#uses=1] - %tmp.upgrd.7 = load i32* %tmp2 ; <i32> [#uses=1] + %tmp.upgrd.6 = getelementptr %struct.charsequence, %struct.charsequence* %cs, i64 0, i32 1 ; <i32*> [#uses=1] + %tmp2 = getelementptr %struct.charsequence, %struct.charsequence* @C.0.2294, i64 0, i32 1 ; <i32*> [#uses=1] + %tmp.upgrd.7 = load i32, i32* %tmp2 ; <i32> [#uses=1] store i32 %tmp.upgrd.7, i32* %tmp.upgrd.6 - %tmp3 = getelementptr %struct.charsequence* %cs, i64 0, i32 2 ; <i32*> [#uses=1] - %tmp4 = getelementptr %struct.charsequence* @C.0.2294, i64 0, i32 2 ; <i32*> [#uses=1] - %tmp5 = load i32* %tmp4 ; <i32> [#uses=1] + %tmp3 = getelementptr %struct.charsequence, %struct.charsequence* %cs, i64 0, i32 2 ; <i32*> [#uses=1] + %tmp4 = getelementptr %struct.charsequence, %struct.charsequence* @C.0.2294, i64 0, i32 2 ; <i32*> [#uses=1] + %tmp5 = load i32, i32* %tmp4 ; <i32> [#uses=1] store i32 %tmp5, i32* %tmp3 br label %bb33 bb: ; preds = %bb33 - %tmp.upgrd.8 = load %struct.FILE** %f_addr ; <%struct.FILE*> [#uses=1] + %tmp.upgrd.8 = load %struct.FILE*, %struct.FILE** %f_addr ; <%struct.FILE*> [#uses=1] %tmp.upgrd.9 = call i32 @_IO_getc( %struct.FILE* %tmp.upgrd.8 ) ; <i32> [#uses=1] %tmp6 = call i32 @tolower( i32 %tmp.upgrd.9 ) ; <i32> [#uses=1] %tmp6.upgrd.10 = trunc i32 %tmp6 to i8 ; <i8> [#uses=1] store i8 %tmp6.upgrd.10, i8* %c - %tmp7 = load i32* %wstate ; <i32> [#uses=1] + %tmp7 = load i32, i32* %wstate ; <i32> [#uses=1] %tmp.upgrd.11 = icmp ne i32 %tmp7, 0 ; <i1> [#uses=1] br i1 %tmp.upgrd.11, label %cond_true, label %cond_false cond_true: ; preds = %bb - %tmp.upgrd.12 = load i8* %c ; <i8> [#uses=1] + %tmp.upgrd.12 = load i8, i8* %c ; <i8> [#uses=1] %tmp8 = icmp sle i8 %tmp.upgrd.12, 96 ; <i1> [#uses=1] br i1 %tmp8, label %cond_true9, label %cond_next cond_true9: ; preds = %cond_true br label %bb16 cond_next: ; preds = %cond_true - %tmp10 = load i8* %c ; <i8> [#uses=1] + %tmp10 = load i8, i8* %c ; <i8> [#uses=1] %tmp11 = icmp sgt i8 %tmp10, 122 ; <i1> [#uses=1] br i1 %tmp11, label %cond_true12, label %cond_next13 cond_true12: ; preds = %cond_next br label %bb16 cond_next13: ; preds = %cond_next - %tmp14 = load i8* %c ; <i8> [#uses=1] + %tmp14 = load i8, i8* %c ; <i8> [#uses=1] %tmp14.upgrd.13 = sext i8 %tmp14 to i32 ; <i32> [#uses=1] %tmp1415 = trunc i32 %tmp14.upgrd.13 to i8 ; <i8> [#uses=1] call void @charsequence_push( %struct.charsequence* %cs, i8 %tmp1415 ) @@ -88,26 +88,26 @@ cond_next13: ; preds = %cond_next bb16: ; preds = %cond_true12, %cond_true9 %tmp17 = call i8* @charsequence_val( %struct.charsequence* %cs ) ; <i8*> [#uses=1] store i8* %tmp17, i8** %str - %tmp.upgrd.14 = load %struct.trie_s** %t_addr ; <%struct.trie_s*> [#uses=1] - %tmp18 = load i8** %str ; <i8*> [#uses=1] + %tmp.upgrd.14 = load %struct.trie_s*, %struct.trie_s** %t_addr ; <%struct.trie_s*> [#uses=1] + %tmp18 = load i8*, i8** %str ; <i8*> [#uses=1] %tmp19 = call %struct.trie_s* @trie_insert( %struct.trie_s* %tmp.upgrd.14, i8* %tmp18 ) ; <%struct.trie_s*> [#uses=0] - %tmp20 = load i8** %str ; <i8*> [#uses=1] + %tmp20 = load i8*, i8** %str ; <i8*> [#uses=1] call void @free( i8* %tmp20 ) store i32 0, i32* %wstate br label %bb21 bb21: ; preds = %bb16, %cond_next13 br label %cond_next32 cond_false: ; preds = %bb - %tmp22 = load i8* %c ; <i8> [#uses=1] + %tmp22 = load i8, i8* %c ; <i8> [#uses=1] %tmp23 = icmp sgt i8 %tmp22, 96 ; <i1> [#uses=1] br i1 %tmp23, label %cond_true24, label %cond_next31 cond_true24: ; preds = %cond_false - %tmp25 = load i8* %c ; <i8> [#uses=1] + %tmp25 = load i8, i8* %c ; <i8> [#uses=1] %tmp26 = icmp sle i8 %tmp25, 122 ; <i1> [#uses=1] br i1 %tmp26, label %cond_true27, label %cond_next30 cond_true27: ; preds = %cond_true24 call void @charsequence_reset( %struct.charsequence* %cs ) - %tmp28 = load i8* %c ; <i8> [#uses=1] + %tmp28 = load i8, i8* %c ; <i8> [#uses=1] %tmp28.upgrd.15 = sext i8 %tmp28 to i32 ; <i32> [#uses=1] %tmp2829 = trunc i32 %tmp28.upgrd.15 to i8 ; <i8> [#uses=1] call void @charsequence_push( %struct.charsequence* %cs, i8 %tmp2829 ) @@ -120,7 +120,7 @@ cond_next31: ; preds = %cond_next30, %cond_false cond_next32: ; preds = %cond_next31, %bb21 br label %bb33 bb33: ; preds = %cond_next32, %entry - %tmp34 = load %struct.FILE** %f_addr ; <%struct.FILE*> [#uses=1] + %tmp34 = load %struct.FILE*, %struct.FILE** %f_addr ; <%struct.FILE*> [#uses=1] %tmp35 = call i32 @feof( %struct.FILE* %tmp34 ) ; <i32> [#uses=1] %tmp36 = icmp eq i32 %tmp35, 0 ; <i1> [#uses=1] br i1 %tmp36, label %bb, label %bb37 diff --git a/test/Transforms/SimplifyCFG/2007-11-22-InvokeNoUnwind.ll b/test/Transforms/SimplifyCFG/2007-11-22-InvokeNoUnwind.ll index a90e07276253..76f41e8fc218 100644 --- a/test/Transforms/SimplifyCFG/2007-11-22-InvokeNoUnwind.ll +++ b/test/Transforms/SimplifyCFG/2007-11-22-InvokeNoUnwind.ll @@ -12,5 +12,9 @@ Cont: ; preds = %0 ret i32 0 Other: ; preds = %0 + landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 + catch i8* null ret i32 1 } + +declare i32 @__gxx_personality_v0(...) diff --git a/test/Transforms/SimplifyCFG/2007-12-21-Crash.ll b/test/Transforms/SimplifyCFG/2007-12-21-Crash.ll index 46df0f0ed071..99041ede5d98 100644 --- a/test/Transforms/SimplifyCFG/2007-12-21-Crash.ll +++ b/test/Transforms/SimplifyCFG/2007-12-21-Crash.ll @@ -13,7 +13,7 @@ bb5.outer: ; preds = %bb5.outer.loopexit, %entry br label %bb5 bb5: ; preds = %bb5, %bb5.outer - %tmp6 = tail call i32 (...)* @foo( ) nounwind ; <i32> [#uses=1] + %tmp6 = tail call i32 (...) @foo( ) nounwind ; <i32> [#uses=1] switch i32 %tmp6, label %bb13 [ i32 -1, label %bb10 i32 102, label %bb5 @@ -21,7 +21,7 @@ bb5: ; preds = %bb5, %bb5.outer ] bb10: ; preds = %bb5 - %tmp12 = tail call i32 (...)* @bar( i32 %undo.0.ph ) nounwind ; <i32> [#uses=0] + %tmp12 = tail call i32 (...) @bar( i32 %undo.0.ph ) nounwind ; <i32> [#uses=0] br label %UnifiedReturnBlock bb13: ; preds = %bb5 diff --git a/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll b/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll index cf29b7159793..7625d935ab3d 100644 --- a/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll +++ b/test/Transforms/SimplifyCFG/2008-01-02-hoist-fp-add.ll @@ -1,27 +1,27 @@ -; The phi should not be eliminated in this case, because the fp op could trap. +; The phi should not be eliminated in this case, because the divide op could trap. ; RUN: opt < %s -simplifycfg -S | FileCheck %s target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i686-apple-darwin8" -@G = weak global double 0.000000e+00, align 8 ; <double*> [#uses=2] +@G = weak global i32 0, align 8 ; <i32*> [#uses=2] -define void @test(i32 %X, i32 %Y, double %Z) { +define void @test(i32 %X, i32 %Y, i32 %Z) { entry: %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] - %tmp = load double* @G, align 8 ; <double> [#uses=2] + %tmp = load i32, i32* @G, align 8 ; <i32> [#uses=2] %tmp3 = icmp eq i32 %X, %Y ; <i1> [#uses=1] %tmp34 = zext i1 %tmp3 to i8 ; <i8> [#uses=1] %toBool = icmp ne i8 %tmp34, 0 ; <i1> [#uses=1] br i1 %toBool, label %cond_true, label %cond_next cond_true: ; preds = %entry - %tmp7 = fadd double %tmp, %Z ; <double> [#uses=1] + %tmp7 = udiv i32 %tmp, %Z ; <i32> [#uses=1] br label %cond_next cond_next: ; preds = %cond_true, %entry -; CHECK: = phi double - %F.0 = phi double [ %tmp, %entry ], [ %tmp7, %cond_true ] ; <double> [#uses=1] - store double %F.0, double* @G, align 8 +; CHECK: = phi i32 + %F.0 = phi i32 [ %tmp, %entry ], [ %tmp7, %cond_true ] ; <i32> [#uses=1] + store i32 %F.0, i32* @G, align 8 ret void } diff --git a/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll b/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll index 9b6084f0e1af..154677b0747f 100644 --- a/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll +++ b/test/Transforms/SimplifyCFG/2008-07-13-InfLoopMiscompile.ll @@ -9,7 +9,7 @@ target triple = "i386-pc-linux-gnu" define i32 @main() nounwind { entry: - %l = load i32* @g_37, align 4 ; <i32> [#uses=1] + %l = load i32, i32* @g_37, align 4 ; <i32> [#uses=1] %cmpa = icmp ne i32 %l, 0 ; <i1> [#uses=3] br i1 %cmpa, label %func_1.exit, label %mooseblock @@ -29,7 +29,7 @@ cowblock: ; preds = %beeblock, %monkeyblock func_1.exit: ; preds = %cowblock, %entry %outval = phi i32 [ %cowval, %cowblock ], [ 1, %entry ] ; <i32> [#uses=1] - %pout = tail call i32 (i8*, ...)* @printf( i8* noalias getelementptr ([4 x i8]* @.str, i32 0, i32 0), i32 %outval ) nounwind ; <i32> [#uses=0] + %pout = tail call i32 (i8*, ...) @printf( i8* noalias getelementptr ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %outval ) nounwind ; <i32> [#uses=0] ret i32 0 } diff --git a/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll b/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll index ac9622d43c31..6b216f598efb 100644 --- a/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll +++ b/test/Transforms/SimplifyCFG/2008-09-08-MultiplePred.ll @@ -4,7 +4,7 @@ define i32 @func_127(i32 %p_129) nounwind { entry: - load i32* @g_103, align 4 ; <i32>:0 [#uses=1] + load i32, i32* @g_103, align 4 ; <i32>:0 [#uses=1] icmp eq i32 %0, 0 ; <i1>:1 [#uses=2] br i1 %1, label %bb6.preheader, label %entry.return_crit_edge diff --git a/test/Transforms/SimplifyCFG/2008-12-16-DCECond.ll b/test/Transforms/SimplifyCFG/2008-12-16-DCECond.ll index 727102435fc7..4fc21d942237 100644 --- a/test/Transforms/SimplifyCFG/2008-12-16-DCECond.ll +++ b/test/Transforms/SimplifyCFG/2008-12-16-DCECond.ll @@ -9,7 +9,7 @@ entry: br i1 %cmp, label %ifthen, label %ifend ifthen: ; preds = %entry - %call = call i32 (...)* @foo() ; <i32> [#uses=0] + %call = call i32 (...) @foo() ; <i32> [#uses=0] br label %ifend ifend: ; preds = %ifthen, %entry @@ -17,7 +17,7 @@ ifend: ; preds = %ifthen, %entry br i1 %cmp2, label %ifthen3, label %ifend5 ifthen3: ; preds = %ifend - %call4 = call i32 (...)* @foo() ; <i32> [#uses=0] + %call4 = call i32 (...) @foo() ; <i32> [#uses=0] br label %ifend5 ifend5: ; preds = %ifthen3, %ifend @@ -25,7 +25,7 @@ ifend5: ; preds = %ifthen3, %ifend br i1 %cmp7, label %ifthen8, label %ifend10 ifthen8: ; preds = %ifend5 - %call9 = call i32 (...)* @bar() ; <i32> [#uses=0] + %call9 = call i32 (...) @bar() ; <i32> [#uses=0] br label %ifend10 ifend10: ; preds = %ifthen8, %ifend5 @@ -33,7 +33,7 @@ ifend10: ; preds = %ifthen8, %ifend5 br i1 %cmp12, label %ifthen13, label %ifend15 ifthen13: ; preds = %ifend10 - %call14 = call i32 (...)* @bar() ; <i32> [#uses=0] + %call14 = call i32 (...) @bar() ; <i32> [#uses=0] br label %ifend15 ifend15: ; preds = %ifthen13, %ifend10 diff --git a/test/Transforms/SimplifyCFG/2009-05-12-externweak.ll b/test/Transforms/SimplifyCFG/2009-05-12-externweak.ll index 419feb6b56a1..faf3f5f8b2a7 100644 --- a/test/Transforms/SimplifyCFG/2009-05-12-externweak.ll +++ b/test/Transforms/SimplifyCFG/2009-05-12-externweak.ll @@ -18,7 +18,7 @@ bb: ; preds = %bb4 br i1 icmp ne (i32* @i, i32* null), label %bb1, label %bb2 bb1: ; preds = %bb - %0 = load i32* @i, align 4 ; <i32> [#uses=1] + %0 = load i32, i32* @i, align 4 ; <i32> [#uses=1] br label %bb3 bb2: ; preds = %bb diff --git a/test/Transforms/SimplifyCFG/AArch64/lit.local.cfg b/test/Transforms/SimplifyCFG/AArch64/lit.local.cfg new file mode 100644 index 000000000000..6642d2870680 --- /dev/null +++ b/test/Transforms/SimplifyCFG/AArch64/lit.local.cfg @@ -0,0 +1,5 @@ +config.suffixes = ['.ll'] + +targets = set(config.root.targets_to_build.split()) +if not 'AArch64' in targets: + config.unsupported = True diff --git a/test/Transforms/SimplifyCFG/AArch64/prefer-fma.ll b/test/Transforms/SimplifyCFG/AArch64/prefer-fma.ll new file mode 100644 index 000000000000..cfbe219c4c2d --- /dev/null +++ b/test/Transforms/SimplifyCFG/AArch64/prefer-fma.ll @@ -0,0 +1,72 @@ +; RUN: opt < %s -mtriple=aarch64-linux-gnu -simplifycfg -enable-unsafe-fp-math -S >%t +; RUN: FileCheck %s < %t +; ModuleID = 't.cc' + +; Function Attrs: nounwind +define double @_Z3fooRdS_S_S_(double* dereferenceable(8) %x, double* dereferenceable(8) %y, double* dereferenceable(8) %a) #0 { +entry: + %0 = load double, double* %y, align 8 + %cmp = fcmp oeq double %0, 0.000000e+00 + %1 = load double, double* %x, align 8 + br i1 %cmp, label %if.then, label %if.else + +; fadd (const, (fmul x, y)) +if.then: ; preds = %entry +; CHECK-LABEL: if.then: +; CHECK: %3 = fmul fast double %1, %2 +; CHECK-NEXT: %mul = fadd fast double 1.000000e+00, %3 + %2 = load double, double* %a, align 8 + %3 = fmul fast double %1, %2 + %mul = fadd fast double 1.000000e+00, %3 + store double %mul, double* %y, align 8 + br label %if.end + +; fsub ((fmul x, y), z) +if.else: ; preds = %entry +; CHECK-LABEL: if.else: +; CHECK: %mul1 = fmul fast double %1, %2 +; CHECK-NEXT: %sub1 = fsub fast double %mul1, %0 + %4 = load double, double* %a, align 8 + %mul1 = fmul fast double %1, %4 + %sub1 = fsub fast double %mul1, %0 + store double %sub1, double* %y, align 8 + br label %if.end + +if.end: ; preds = %if.else, %if.then + %5 = load double, double* %y, align 8 + %cmp2 = fcmp oeq double %5, 2.000000e+00 + %6 = load double, double* %x, align 8 + br i1 %cmp2, label %if.then2, label %if.else2 + +; fsub (x, (fmul y, z)) +if.then2: ; preds = %entry +; CHECK-LABEL: if.then2: +; CHECK: %7 = fmul fast double %5, 3.000000e+00 +; CHECK-NEXT: %mul2 = fsub fast double %6, %7 + %7 = load double, double* %a, align 8 + %8 = fmul fast double %6, 3.0000000e+00 + %mul2 = fsub fast double %7, %8 + store double %mul2, double* %y, align 8 + br label %if.end2 + +; fsub (fneg((fmul x, y)), const) +if.else2: ; preds = %entry +; CHECK-LABEL: if.else2: +; CHECK: %mul3 = fmul fast double %5, 3.000000e+00 +; CHECK-NEXT: %neg = fsub fast double 0.000000e+00, %mul3 +; CHECK-NEXT: %sub2 = fsub fast double %neg, 3.000000e+00 + %mul3 = fmul fast double %6, 3.0000000e+00 + %neg = fsub fast double 0.0000000e+00, %mul3 + %sub2 = fsub fast double %neg, 3.0000000e+00 + store double %sub2, double* %y, align 8 + br label %if.end2 + +if.end2: ; preds = %if.else, %if.then + %9 = load double, double* %x, align 8 + %10 = load double, double* %y, align 8 + %add = fadd fast double %9, %10 + %11 = load double, double* %a, align 8 + %add2 = fadd fast double %add, %11 + ret double %add2 +} + diff --git a/test/Transforms/SimplifyCFG/EmptyBlockMerge.ll b/test/Transforms/SimplifyCFG/EmptyBlockMerge.ll index aba08dc073a8..32a0202364d9 100644 --- a/test/Transforms/SimplifyCFG/EmptyBlockMerge.ll +++ b/test/Transforms/SimplifyCFG/EmptyBlockMerge.ll @@ -6,7 +6,7 @@ declare void @foo() define void @cprop_test12(i32* %data) { bb0: - %reg108 = load i32* %data ; <i32> [#uses=2] + %reg108 = load i32, i32* %data ; <i32> [#uses=2] %cond218 = icmp ne i32 %reg108, 5 ; <i1> [#uses=1] br i1 %cond218, label %bb3, label %bb2 bb2: ; preds = %bb0 diff --git a/test/Transforms/SimplifyCFG/MagicPointer.ll b/test/Transforms/SimplifyCFG/MagicPointer.ll index b8b8cbd9dc63..7789600f3f0c 100644 --- a/test/Transforms/SimplifyCFG/MagicPointer.ll +++ b/test/Transforms/SimplifyCFG/MagicPointer.ll @@ -33,7 +33,7 @@ entry: br i1 %tobool, label %if.then, label %if.else if.then: ; preds = %entry - %call = call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + %call = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0] br label %if.end21 if.else: ; preds = %entry @@ -41,7 +41,7 @@ if.else: ; preds = %entry br i1 %cmp, label %if.then2, label %if.else4 if.then2: ; preds = %if.else - %call3 = call i32 @puts(i8* getelementptr inbounds ([4 x i8]* @.str1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + %call3 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] br label %if.end20 if.else4: ; preds = %if.else @@ -53,7 +53,7 @@ lor.lhs.false: ; preds = %if.else4 br i1 %cmp8, label %if.then9, label %if.else11 if.then9: ; preds = %lor.lhs.false, %if.else4 - %call10 = call i32 @puts(i8* getelementptr inbounds ([4 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + %call10 = call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0] br label %if.end19 if.else11: ; preds = %lor.lhs.false @@ -61,7 +61,7 @@ if.else11: ; preds = %lor.lhs.false br i1 %cmp13, label %if.then14, label %if.else16 if.then14: ; preds = %if.else11 - %call15 = call i32 @puts(i8* getelementptr inbounds ([5 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + %call15 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0] br label %if.end if.else16: ; preds = %if.else11 @@ -99,7 +99,7 @@ entry: br i1 %tobool, label %if.then, label %if.else if.then: ; preds = %entry - %call = call i32 @puts_as1(i8 addrspace(1)* getelementptr inbounds ([5 x i8] addrspace(1)* @.str_as1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + %call = call i32 @puts_as1(i8 addrspace(1)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(1)* @.str_as1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] br label %if.end21 if.else: ; preds = %entry @@ -107,7 +107,7 @@ if.else: ; preds = %entry br i1 %cmp, label %if.then2, label %if.else4 if.then2: ; preds = %if.else - %call3 = call i32 @puts_as1(i8 addrspace(1)* getelementptr inbounds ([4 x i8] addrspace(1)* @.str1_as1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + %call3 = call i32 @puts_as1(i8 addrspace(1)* getelementptr inbounds ([4 x i8], [4 x i8] addrspace(1)* @.str1_as1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] br label %if.end20 if.else4: ; preds = %if.else @@ -119,7 +119,7 @@ lor.lhs.false: ; preds = %if.else4 br i1 %cmp8, label %if.then9, label %if.else11 if.then9: ; preds = %lor.lhs.false, %if.else4 - %call10 = call i32 @puts_as1(i8 addrspace(1)* getelementptr inbounds ([4 x i8] addrspace(1)* @.str2_as1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + %call10 = call i32 @puts_as1(i8 addrspace(1)* getelementptr inbounds ([4 x i8], [4 x i8] addrspace(1)* @.str2_as1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] br label %if.end19 if.else11: ; preds = %lor.lhs.false @@ -127,7 +127,7 @@ if.else11: ; preds = %lor.lhs.false br i1 %cmp13, label %if.then14, label %if.else16 if.then14: ; preds = %if.else11 - %call15 = call i32 @puts_as1(i8 addrspace(1)* getelementptr inbounds ([5 x i8] addrspace(1)* @.str3_as1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] + %call15 = call i32 @puts_as1(i8 addrspace(1)* getelementptr inbounds ([5 x i8], [5 x i8] addrspace(1)* @.str3_as1, i64 0, i64 0)) nounwind ; <i32> [#uses=0] br label %if.end if.else16: ; preds = %if.else11 diff --git a/test/Transforms/SimplifyCFG/PR17073.ll b/test/Transforms/SimplifyCFG/PR17073.ll index 8dc9fb28d617..e6e98b266879 100644 --- a/test/Transforms/SimplifyCFG/PR17073.ll +++ b/test/Transforms/SimplifyCFG/PR17073.ll @@ -18,7 +18,7 @@ target triple = "i386-apple-macosx10.9.0" ; CHECK-NOT: select i1 %tobool, i32* null, i32* select (i1 icmp eq (i64 urem (i64 2, i64 zext (i1 icmp eq (i32* bitcast (i8* @b to i32*), i32* @a) to i64)), i64 0), i32* null, i32* @a) define i32* @can_trap1() { entry: - %0 = load i32* @a, align 4 + %0 = load i32, i32* @a, align 4 %tobool = icmp eq i32 %0, 0 br i1 %tobool, label %exit, label %block1 @@ -38,7 +38,7 @@ exit: ; CHECK-NOT: select i1 %tobool, i32* select (i1 icmp eq (i64 urem (i64 2, i64 zext (i1 icmp eq (i32* bitcast (i8* @b to i32*), i32* @a) to i64)), i64 0), i32* null, i32* @a), i32* null define i32* @can_trap2() { entry: - %0 = load i32* @a, align 4 + %0 = load i32, i32* @a, align 4 %tobool = icmp eq i32 %0, 0 br i1 %tobool, label %exit, label %block1 @@ -57,7 +57,7 @@ exit: ; CHECK: select i1 icmp eq (i32* bitcast (i8* @b to i32*), i32* @a), i32* select (i1 icmp eq (i64 add (i64 zext (i1 icmp eq (i32* bitcast (i8* @b to i32*), i32* @a) to i64), i64 2), i64 0), i32* null, i32* @a), i32* null define i32* @cannot_trap() { entry: - %0 = load i32* @a, align 4 + %0 = load i32, i32* @a, align 4 %tobool = icmp eq i32 %0, 0 br i1 %tobool, label %exit, label %block1 diff --git a/test/Transforms/SimplifyCFG/PhiBlockMerge.ll b/test/Transforms/SimplifyCFG/PhiBlockMerge.ll index 36b52f52d490..555082921b96 100644 --- a/test/Transforms/SimplifyCFG/PhiBlockMerge.ll +++ b/test/Transforms/SimplifyCFG/PhiBlockMerge.ll @@ -4,9 +4,7 @@ ; define i32 @test(i1 %a, i1 %b) { -; CHECK: br i1 %a br i1 %a, label %M, label %O -; CHECK: O: O: ; preds = %0 ; CHECK: select i1 %b, i32 0, i32 1 ; CHECK-NOT: phi @@ -18,9 +16,9 @@ N: ; preds = %Q, %O %Wp = phi i32 [ 0, %O ], [ 1, %Q ] ; <i32> [#uses=1] br label %M M: ; preds = %N, %0 -; CHECK: %W = phi i32 %W = phi i32 [ %Wp, %N ], [ 2, %0 ] ; <i32> [#uses=1] %R = add i32 %W, 1 ; <i32> [#uses=1] ret i32 %R +; CHECK: ret } diff --git a/test/Transforms/SimplifyCFG/PowerPC/cttz-ctlz-spec.ll b/test/Transforms/SimplifyCFG/PowerPC/cttz-ctlz-spec.ll new file mode 100644 index 000000000000..fa74549710f4 --- /dev/null +++ b/test/Transforms/SimplifyCFG/PowerPC/cttz-ctlz-spec.ll @@ -0,0 +1,45 @@ +; RUN: opt -S -simplifycfg < %s | FileCheck %s +target datalayout = "E-m:e-i64:64-n32:64" +target triple = "powerpc64-unknown-linux-gnu" + +define i64 @test1(i64 %A) { +; CHECK-LABEL: @test1( +; CHECK: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 +; CHECK-NEXT: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) +; CHECK-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i64 64, i64 [[CTLZ]] +; CHECK-NEXT: ret i64 [[SEL]] +entry: + %tobool = icmp eq i64 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] + ret i64 %cond +} + +define i64 @test1b(i64 %A) { +; CHECK-LABEL: @test1b( +; CHECK: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 +; CHECK-NEXT: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) +; CHECK-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i64 64, i64 [[CTLZ]] +; CHECK-NEXT: ret i64 [[SEL]] +entry: + %tobool = icmp eq i64 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] + ret i64 %cond +} + +declare i64 @llvm.ctlz.i64(i64, i1) +declare i64 @llvm.cttz.i64(i64, i1) + diff --git a/test/Transforms/SimplifyCFG/PowerPC/lit.local.cfg b/test/Transforms/SimplifyCFG/PowerPC/lit.local.cfg new file mode 100644 index 000000000000..091332439b18 --- /dev/null +++ b/test/Transforms/SimplifyCFG/PowerPC/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'PowerPC' in config.root.targets: + config.unsupported = True diff --git a/test/Transforms/SimplifyCFG/R600/cttz-ctlz.ll b/test/Transforms/SimplifyCFG/R600/cttz-ctlz.ll new file mode 100644 index 000000000000..5b2799494647 --- /dev/null +++ b/test/Transforms/SimplifyCFG/R600/cttz-ctlz.ll @@ -0,0 +1,249 @@ +; RUN: opt -S -simplifycfg -mtriple=r600-unknown-unknown -mcpu=SI < %s | FileCheck -check-prefix=SI -check-prefix=ALL %s +; RUN: opt -S -simplifycfg -mtriple=r600-unknown-unknown -mcpu=tonga < %s | FileCheck -check-prefix=SI -check-prefix=ALL %s + + +define i64 @test1(i64 %A) { +; ALL-LABEL: @test1( +; SI: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 +; SI-NEXT: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) +; SI-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i64 64, i64 [[CTLZ]] +; SI-NEXT: ret i64 [[SEL]] +entry: + %tobool = icmp eq i64 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] + ret i64 %cond +} + + +define i32 @test2(i32 %A) { +; ALL-LABEL: @test2( +; SI: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 +; SI-NEXT: [[CTLZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) +; SI-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i32 32, i32 [[CTLZ]] +; SI-NEXT: ret i32 [[SEL]] +entry: + %tobool = icmp eq i32 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ] + ret i32 %cond +} + + +define signext i16 @test3(i16 signext %A) { +; ALL-LABEL: @test3( +; SI: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 +; SI-NEXT: [[CTLZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) +; SI-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i16 16, i16 [[CTLZ]] +; SI-NEXT: ret i16 [[SEL]] +entry: + %tobool = icmp eq i16 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %0, %cond.true ], [ 16, %entry ] + ret i16 %cond +} + + +define i64 @test1b(i64 %A) { +; ALL-LABEL: @test1b( +; SI: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 +; SI-NEXT: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) +; SI-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i64 64, i64 [[CTTZ]] +; SI-NEXT: ret i64 [[SEL]] +entry: + %tobool = icmp eq i64 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] + ret i64 %cond +} + + +define i32 @test2b(i32 %A) { +; ALL-LABEL: @test2b( +; SI: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 +; SI-NEXT: [[CTTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) +; SI-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i32 32, i32 [[CTTZ]] +; SI-NEXT: ret i32 [[SEL]] +entry: + %tobool = icmp eq i32 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ] + ret i32 %cond +} + + +define signext i16 @test3b(i16 signext %A) { +; ALL-LABEL: @test3b( +; SI: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 +; SI-NEXT: [[CTTZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) +; SI-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i16 16, i16 [[CTTZ]] +; SI-NEXT: ret i16 [[SEL]] +entry: + %tobool = icmp eq i16 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %0, %cond.true ], [ 16, %entry ] + ret i16 %cond +} + + +define i64 @test1c(i64 %A) { +; ALL-LABEL: @test1c( +; ALL: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 +; ALL-NEXT: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) +; ALL-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i64 63, i64 [[CTLZ]] +; ALL-NEXT: ret i64 [[SEL]] +entry: + %tobool = icmp eq i64 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %0, %cond.true ], [ 63, %entry ] + ret i64 %cond +} + +define i32 @test2c(i32 %A) { +; ALL-LABEL: @test2c( +; ALL: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 +; ALL-NEXT: [[CTLZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) +; ALL-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i32 31, i32 [[CTLZ]] +; ALL-NEXT: ret i32 [[SEL]] +entry: + %tobool = icmp eq i32 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i32 [ %0, %cond.true ], [ 31, %entry ] + ret i32 %cond +} + + +define signext i16 @test3c(i16 signext %A) { +; ALL-LABEL: @test3c( +; ALL: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 +; ALL-NEXT: [[CTLZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) +; ALL-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i16 15, i16 [[CTLZ]] +; ALL-NEXT: ret i16 [[SEL]] +entry: + %tobool = icmp eq i16 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %0, %cond.true ], [ 15, %entry ] + ret i16 %cond +} + + +define i64 @test1d(i64 %A) { +; ALL-LABEL: @test1d( +; ALL: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 +; ALL-NEXT: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) +; ALL-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i64 63, i64 [[CTTZ]] +; ALL-NEXT: ret i64 [[SEL]] +entry: + %tobool = icmp eq i64 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %0, %cond.true ], [ 63, %entry ] + ret i64 %cond +} + + +define i32 @test2d(i32 %A) { +; ALL-LABEL: @test2d( +; ALL: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 +; ALL-NEXT: [[CTTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) +; ALL-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i32 31, i32 [[CTTZ]] +; ALL-NEXT: ret i32 [[SEL]] +entry: + %tobool = icmp eq i32 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i32 [ %0, %cond.true ], [ 31, %entry ] + ret i32 %cond +} + + +define signext i16 @test3d(i16 signext %A) { +; ALL-LABEL: @test3d( +; ALL: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 +; ALL-NEXT: [[CTTZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) +; ALL-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i16 15, i16 [[CTTZ]] +; ALL-NEXT: ret i16 [[SEL]] +entry: + %tobool = icmp eq i16 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %0, %cond.true ], [ 15, %entry ] + ret i16 %cond +} + + +declare i64 @llvm.ctlz.i64(i64, i1) +declare i32 @llvm.ctlz.i32(i32, i1) +declare i16 @llvm.ctlz.i16(i16, i1) +declare i64 @llvm.cttz.i64(i64, i1) +declare i32 @llvm.cttz.i32(i32, i1) +declare i16 @llvm.cttz.i16(i16, i1) diff --git a/test/Transforms/SimplifyCFG/R600/lit.local.cfg b/test/Transforms/SimplifyCFG/R600/lit.local.cfg new file mode 100644 index 000000000000..ad9ce2541ef7 --- /dev/null +++ b/test/Transforms/SimplifyCFG/R600/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'R600' in config.root.targets: + config.unsupported = True diff --git a/test/Transforms/SimplifyCFG/SpeculativeExec.ll b/test/Transforms/SimplifyCFG/SpeculativeExec.ll index 83fa41900035..c23a96df52ee 100644 --- a/test/Transforms/SimplifyCFG/SpeculativeExec.ll +++ b/test/Transforms/SimplifyCFG/SpeculativeExec.ll @@ -28,33 +28,17 @@ bb3: ; preds = %bb2, %entry ret i32 %tmp5 } -declare i8 @llvm.cttz.i8(i8, i1) - -define i8 @test2(i8 %a) { -; CHECK-LABEL: @test2( - br i1 undef, label %bb_true, label %bb_false -bb_true: - %b = tail call i8 @llvm.cttz.i8(i8 %a, i1 false) - br label %join -bb_false: - br label %join -join: - %c = phi i8 [%b, %bb_true], [%a, %bb_false] -; CHECK: select - ret i8 %c -} - define i8* @test4(i1* %dummy, i8* %a, i8* %b) { ; Test that we don't speculate an arbitrarily large number of unfolded constant ; expressions. ; CHECK-LABEL: @test4( entry: - %cond1 = load volatile i1* %dummy + %cond1 = load volatile i1, i1* %dummy br i1 %cond1, label %if, label %end if: - %cond2 = load volatile i1* %dummy + %cond2 = load volatile i1, i1* %dummy br i1 %cond2, label %then, label %end then: diff --git a/test/Transforms/SimplifyCFG/UnreachableEliminate.ll b/test/Transforms/SimplifyCFG/UnreachableEliminate.ll index 21428c62f531..8718c552c693 100644 --- a/test/Transforms/SimplifyCFG/UnreachableEliminate.ll +++ b/test/Transforms/SimplifyCFG/UnreachableEliminate.ll @@ -22,11 +22,15 @@ entry: invoke void @test2( ) to label %N unwind label %U U: + %res = landingpad { i8* } personality i32 (...)* @__gxx_personality_v0 + cleanup unreachable N: ret void } +declare i32 @__gxx_personality_v0(...) + define i32 @test3(i32 %v) { ; CHECK-LABEL: @test3( ; CHECK: entry: @@ -46,32 +50,6 @@ T: ret i32 2 } -; PR9450 -define i32 @test4(i32 %v, i32 %w) { -; CHECK: entry: -; CHECK-NEXT: switch i32 %v, label %T [ -; CHECK-NEXT: i32 3, label %V -; CHECK-NEXT: i32 2, label %U -; CHECK-NEXT: ] - -entry: - br label %SWITCH -V: - ret i32 7 -SWITCH: - switch i32 %v, label %default [ - i32 1, label %T - i32 2, label %U - i32 3, label %V - ] -default: - unreachable -U: - ret i32 %w -T: - ret i32 2 -} - ;; We can either convert the following control-flow to a select or remove the ;; unreachable control flow because of the undef store of null. Make sure we do diff --git a/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll b/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll new file mode 100644 index 000000000000..69f6c69059d4 --- /dev/null +++ b/test/Transforms/SimplifyCFG/X86/speculate-cttz-ctlz.ll @@ -0,0 +1,330 @@ +; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown -mattr=+bmi < %s | FileCheck %s --check-prefix=ALL --check-prefix=BMI +; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown -mattr=+lzcnt < %s | FileCheck %s --check-prefix=ALL --check-prefix=LZCNT +; RUN: opt -S -simplifycfg -mtriple=x86_64-unknown-unknown < %s | FileCheck %s --check-prefix=ALL --check-prefix=GENERIC + + +define i64 @test1(i64 %A) { +; ALL-LABEL: @test1( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 +; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) +; LZCNT-NEXT: select i1 [[COND]], i64 64, i64 [[CTLZ]] +; BMI-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i64 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] + ret i64 %cond +} + +define i32 @test2(i32 %A) { +; ALL-LABEL: @test2( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 +; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) +; LZCNT-NEXT: select i1 [[COND]], i32 32, i32 [[CTLZ]] +; BMI-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i32 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ] + ret i32 %cond +} + + +define signext i16 @test3(i16 signext %A) { +; ALL-LABEL: @test3( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 +; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) +; LZCNT-NEXT: select i1 [[COND]], i16 16, i16 [[CTLZ]] +; BMI-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i16 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %0, %cond.true ], [ 16, %entry ] + ret i16 %cond +} + + +define i64 @test1b(i64 %A) { +; ALL-LABEL: @test1b( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 +; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) +; BMI-NEXT: select i1 [[COND]], i64 64, i64 [[CTTZ]] +; LZCNT-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i64 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] + ret i64 %cond +} + + +define i32 @test2b(i32 %A) { +; ALL-LABEL: @test2b( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0 +; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) +; BMI-NEXT: select i1 [[COND]], i32 32, i32 [[CTTZ]] +; LZCNT-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i32 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.cttz.i32(i32 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ] + ret i32 %cond +} + + +define signext i16 @test3b(i16 signext %A) { +; ALL-LABEL: @test3b( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i16 %A, 0 +; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) +; BMI-NEXT: select i1 [[COND]], i16 16, i16 [[CTTZ]] +; LZCNT-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i16 %A, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i16 @llvm.cttz.i16(i16 %A, i1 true) + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %0, %cond.true ], [ 16, %entry ] + ret i16 %cond +} + +; The following tests verify that calls to cttz/ctlz are speculated even if +; basic block %cond.true has an extra zero extend/truncate which is "free" +; for the target. + +define i64 @test1e(i32 %x) { +; ALL-LABEL: @test1e( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %x, 0 +; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %x, i1 true) +; ALL: [[ZEXT:%[A-Za-z0-9]+]] = zext i32 [[CTTZ]] to i64 +; BMI-NEXT: select i1 [[COND]], i64 32, i64 [[ZEXT]] +; LZCNT-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i32 %x, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.cttz.i32(i32 %x, i1 true) + %phitmp2 = zext i32 %0 to i64 + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %phitmp2, %cond.true ], [ 32, %entry ] + ret i64 %cond +} + +define i32 @test2e(i64 %x) { +; ALL-LABEL: @test2e( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %x, 0 +; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %x, i1 true) +; ALL: [[TRUNC:%[A-Za-z0-9]+]] = trunc i64 [[CTTZ]] to i32 +; BMI-NEXT: select i1 [[COND]], i32 64, i32 [[TRUNC]] +; LZCNT-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i64 %x, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.cttz.i64(i64 %x, i1 true) + %cast = trunc i64 %0 to i32 + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i32 [ %cast, %cond.true ], [ 64, %entry ] + ret i32 %cond +} + +define i64 @test3e(i32 %x) { +; ALL-LABEL: @test3e( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %x, 0 +; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %x, i1 true) +; ALL: [[ZEXT:%[A-Za-z0-9]+]] = zext i32 [[CTLZ]] to i64 +; LZCNT-NEXT: select i1 [[COND]], i64 32, i64 [[ZEXT]] +; BMI-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i32 %x, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.ctlz.i32(i32 %x, i1 true) + %phitmp2 = zext i32 %0 to i64 + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i64 [ %phitmp2, %cond.true ], [ 32, %entry ] + ret i64 %cond +} + +define i32 @test4e(i64 %x) { +; ALL-LABEL: @test4e( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %x, 0 +; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %x, i1 true) +; ALL: [[TRUNC:%[A-Za-z0-9]+]] = trunc i64 [[CTLZ]] to i32 +; LZCNT-NEXT: select i1 [[COND]], i32 64, i32 [[TRUNC]] +; BMI-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i64 %x, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.ctlz.i64(i64 %x, i1 true) + %cast = trunc i64 %0 to i32 + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i32 [ %cast, %cond.true ], [ 64, %entry ] + ret i32 %cond +} + +define i16 @test5e(i64 %x) { +; ALL-LABEL: @test5e( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %x, 0 +; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %x, i1 true) +; ALL: [[TRUNC:%[A-Za-z0-9]+]] = trunc i64 [[CTLZ]] to i16 +; LZCNT-NEXT: select i1 [[COND]], i16 64, i16 [[TRUNC]] +; BMI-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i64 %x, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.ctlz.i64(i64 %x, i1 true) + %cast = trunc i64 %0 to i16 + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %cast, %cond.true ], [ 64, %entry ] + ret i16 %cond +} + +define i16 @test6e(i32 %x) { +; ALL-LABEL: @test6e( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %x, 0 +; ALL: [[CTLZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %x, i1 true) +; ALL: [[TRUNC:%[A-Za-z0-9]+]] = trunc i32 [[CTLZ]] to i16 +; LZCNT-NEXT: select i1 [[COND]], i16 32, i16 [[TRUNC]] +; BMI-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i32 %x, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.ctlz.i32(i32 %x, i1 true) + %cast = trunc i32 %0 to i16 + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %cast, %cond.true ], [ 32, %entry ] + ret i16 %cond +} + +define i16 @test7e(i64 %x) { +; ALL-LABEL: @test7e( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i64 %x, 0 +; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %x, i1 true) +; ALL: [[TRUNC:%[A-Za-z0-9]+]] = trunc i64 [[CTTZ]] to i16 +; BMI-NEXT: select i1 [[COND]], i16 64, i16 [[TRUNC]] +; LZCNT-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i64 %x, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i64 @llvm.cttz.i64(i64 %x, i1 true) + %cast = trunc i64 %0 to i16 + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %cast, %cond.true ], [ 64, %entry ] + ret i16 %cond +} + +define i16 @test8e(i32 %x) { +; ALL-LABEL: @test8e( +; ALL: [[COND:%[A-Za-z0-9]+]] = icmp eq i32 %x, 0 +; ALL: [[CTTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %x, i1 true) +; ALL: [[TRUNC:%[A-Za-z0-9]+]] = trunc i32 [[CTTZ]] to i16 +; BMI-NEXT: select i1 [[COND]], i16 32, i16 [[TRUNC]] +; LZCNT-NOT: select +; GENERIC-NOT: select +; ALL: ret +entry: + %tobool = icmp eq i32 %x, 0 + br i1 %tobool, label %cond.end, label %cond.true + +cond.true: ; preds = %entry + %0 = tail call i32 @llvm.cttz.i32(i32 %x, i1 true) + %cast = trunc i32 %0 to i16 + br label %cond.end + +cond.end: ; preds = %entry, %cond.true + %cond = phi i16 [ %cast, %cond.true ], [ 32, %entry ] + ret i16 %cond +} + + +declare i64 @llvm.ctlz.i64(i64, i1) +declare i32 @llvm.ctlz.i32(i32, i1) +declare i16 @llvm.ctlz.i16(i16, i1) +declare i64 @llvm.cttz.i64(i64, i1) +declare i32 @llvm.cttz.i32(i32, i1) +declare i16 @llvm.cttz.i16(i16, i1) diff --git a/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll b/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll index 22599b397ed4..f3e5506ad933 100644 --- a/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll +++ b/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll @@ -9,8 +9,8 @@ target triple = "x86_64-apple-darwin12.0.0" ; CHECK: entry: ; CHECK-NEXT: sub i3 %arg, -4 ; CHECK-NEXT: zext i3 %switch.tableidx to i4 -; CHECK-NEXT: getelementptr inbounds [8 x i64]* @switch.table, i32 0, i4 %switch.tableidx.zext -; CHECK-NEXT: load i64* %switch.gep +; CHECK-NEXT: getelementptr inbounds [8 x i64], [8 x i64]* @switch.table, i32 0, i4 %switch.tableidx.zext +; CHECK-NEXT: load i64, i64* %switch.gep ; CHECK-NEXT: add i64 ; CHECK-NEXT: ret i64 define i64 @test(i3 %arg) { diff --git a/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll b/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll index d0b8ab29d26b..26008700f5be 100644 --- a/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll +++ b/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll @@ -8,8 +8,8 @@ target triple = "x86_64-apple-darwin12.0.0" ; CHECK: entry: ; CHECK-NEXT: sub i2 %0, -2 ; CHECK-NEXT: zext i2 %switch.tableidx to i3 -; CHECK-NEXT: getelementptr inbounds [4 x i64]* @switch.table, i32 0, i3 %switch.tableidx.zext -; CHECK-NEXT: load i64* %switch.gep +; CHECK-NEXT: getelementptr inbounds [4 x i64], [4 x i64]* @switch.table, i32 0, i3 %switch.tableidx.zext +; CHECK-NEXT: load i64, i64* %switch.gep ; CHECK-NEXT: ret i64 %switch.load define i64 @_TFO6reduce1E5toRawfS0_FT_Si(i2) { entry: diff --git a/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll b/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll index 22f18cd4d432..cae1a91bd43d 100644 --- a/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll +++ b/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll @@ -7,22 +7,22 @@ target triple = "x86_64-unknown-linux-gnu" ; CHECK: @switch.table = private unnamed_addr constant [7 x i32] [i32 55, i32 123, i32 0, i32 -1, i32 27, i32 62, i32 1] ; The float table for @h -; CHECK: @switch.table1 = private unnamed_addr constant [4 x float] [float 0x40091EB860000000, float 0x3FF3BE76C0000000, float 0x4012449BA0000000, float 0x4001AE1480000000] +; CHECK: @switch.table.1 = private unnamed_addr constant [4 x float] [float 0x40091EB860000000, float 0x3FF3BE76C0000000, float 0x4012449BA0000000, float 0x4001AE1480000000] ; The table for @foostring -; CHECK: @switch.table2 = private unnamed_addr constant [4 x i8*] [i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8]* @.str1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8]* @.str2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8]* @.str3, i64 0, i64 0)] +; CHECK: @switch.table.2 = private unnamed_addr constant [4 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str3, i64 0, i64 0)] ; The table for @earlyreturncrash -; CHECK: @switch.table3 = private unnamed_addr constant [4 x i32] [i32 42, i32 9, i32 88, i32 5] +; CHECK: @switch.table.3 = private unnamed_addr constant [4 x i32] [i32 42, i32 9, i32 88, i32 5] ; The table for @large. -; CHECK: @switch.table4 = private unnamed_addr constant [199 x i32] [i32 1, i32 4, i32 9, +; CHECK: @switch.table.4 = private unnamed_addr constant [199 x i32] [i32 1, i32 4, i32 9, ; The table for @cprop -; CHECK: @switch.table5 = private unnamed_addr constant [7 x i32] [i32 5, i32 42, i32 126, i32 -452, i32 128, i32 6, i32 7] +; CHECK: @switch.table.5 = private unnamed_addr constant [7 x i32] [i32 5, i32 42, i32 126, i32 -452, i32 128, i32 6, i32 7] -; The table for @unreachable -; CHECK: @switch.table6 = private unnamed_addr constant [5 x i32] [i32 0, i32 0, i32 0, i32 1, i32 -1] +; The table for @unreachable_case +; CHECK: @switch.table.6 = private unnamed_addr constant [9 x i32] [i32 0, i32 0, i32 0, i32 2, i32 -1, i32 1, i32 1, i32 1, i32 1] ; A simple int-to-int selection switch. ; It is dense enough to be replaced by table lookup. @@ -58,8 +58,8 @@ return: ; CHECK-NEXT: %0 = icmp ult i32 %switch.tableidx, 7 ; CHECK-NEXT: br i1 %0, label %switch.lookup, label %return ; CHECK: switch.lookup: -; CHECK-NEXT: %switch.gep = getelementptr inbounds [7 x i32]* @switch.table, i32 0, i32 %switch.tableidx -; CHECK-NEXT: %switch.load = load i32* %switch.gep +; CHECK-NEXT: %switch.gep = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table, i32 0, i32 %switch.tableidx +; CHECK-NEXT: %switch.load = load i32, i32* %switch.gep ; CHECK-NEXT: ret i32 %switch.load ; CHECK: return: ; CHECK-NEXT: ret i32 15 @@ -97,8 +97,8 @@ sw.epilog: ; CHECK-NEXT: %switch.shiftamt = mul i32 %switch.tableidx, 8 ; CHECK-NEXT: %switch.downshift = lshr i32 89655594, %switch.shiftamt ; CHECK-NEXT: %switch.masked = trunc i32 %switch.downshift to i8 -; CHECK-NEXT: %switch.gep = getelementptr inbounds [4 x float]* @switch.table1, i32 0, i32 %switch.tableidx -; CHECK-NEXT: %switch.load = load float* %switch.gep +; CHECK-NEXT: %switch.gep = getelementptr inbounds [4 x float], [4 x float]* @switch.table.1, i32 0, i32 %switch.tableidx +; CHECK-NEXT: %switch.load = load float, float* %switch.gep ; CHECK-NEXT: br label %sw.epilog ; CHECK: sw.epilog: ; CHECK-NEXT: %a.0 = phi i8 [ %switch.masked, %switch.lookup ], [ 7, %entry ] @@ -131,11 +131,11 @@ sw.bb3: br label %return sw.default: br label %return return: - %retval.0 = phi i8* [ getelementptr inbounds ([6 x i8]* @.str4, i64 0, i64 0), %sw.default ], - [ getelementptr inbounds ([4 x i8]* @.str3, i64 0, i64 0), %sw.bb3 ], - [ getelementptr inbounds ([4 x i8]* @.str2, i64 0, i64 0), %sw.bb2 ], - [ getelementptr inbounds ([4 x i8]* @.str1, i64 0, i64 0), %sw.bb1 ], - [ getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), %entry ] + %retval.0 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str4, i64 0, i64 0), %sw.default ], + [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str3, i64 0, i64 0), %sw.bb3 ], + [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str2, i64 0, i64 0), %sw.bb2 ], + [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i64 0, i64 0), %sw.bb1 ], + [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %entry ] ret i8* %retval.0 ; CHECK-LABEL: @foostring( @@ -144,8 +144,8 @@ return: ; CHECK-NEXT: %0 = icmp ult i32 %switch.tableidx, 4 ; CHECK-NEXT: br i1 %0, label %switch.lookup, label %return ; CHECK: switch.lookup: -; CHECK-NEXT: %switch.gep = getelementptr inbounds [4 x i8*]* @switch.table2, i32 0, i32 %switch.tableidx -; CHECK-NEXT: %switch.load = load i8** %switch.gep +; CHECK-NEXT: %switch.gep = getelementptr inbounds [4 x i8*], [4 x i8*]* @switch.table.2, i32 0, i32 %switch.tableidx +; CHECK-NEXT: %switch.load = load i8*, i8** %switch.gep ; CHECK-NEXT: ret i8* %switch.load } @@ -173,8 +173,8 @@ sw.epilog: ; CHECK-LABEL: @earlyreturncrash( ; CHECK: switch.lookup: -; CHECK-NEXT: %switch.gep = getelementptr inbounds [4 x i32]* @switch.table3, i32 0, i32 %switch.tableidx -; CHECK-NEXT: %switch.load = load i32* %switch.gep +; CHECK-NEXT: %switch.gep = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.3, i32 0, i32 %switch.tableidx +; CHECK-NEXT: %switch.load = load i32, i32* %switch.gep ; CHECK-NEXT: ret i32 %switch.load ; CHECK: sw.epilog: ; CHECK-NEXT: ret i32 7 @@ -749,10 +749,10 @@ return: ; CHECK-LABEL: @cprop( ; CHECK: switch.lookup: -; CHECK: %switch.gep = getelementptr inbounds [7 x i32]* @switch.table5, i32 0, i32 %switch.tableidx +; CHECK: %switch.gep = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.5, i32 0, i32 %switch.tableidx } -define i32 @unreachable(i32 %x) { +define i32 @unreachable_case(i32 %x) { entry: switch i32 %x, label %sw.default [ i32 0, label %sw.bb @@ -770,15 +770,44 @@ sw.bb: br label %return sw.bb1: unreachable sw.bb2: br label %return sw.bb3: br label %return -sw.default: unreachable +sw.default: br label %return return: - %retval.0 = phi i32 [ 1, %sw.bb3 ], [ -1, %sw.bb2 ], [ 0, %sw.bb ] + %retval.0 = phi i32 [ 1, %sw.bb3 ], [ -1, %sw.bb2 ], [ 0, %sw.bb ], [ 2, %sw.default ] ret i32 %retval.0 -; CHECK-LABEL: @unreachable( +; CHECK-LABEL: @unreachable_case( ; CHECK: switch.lookup: -; CHECK: getelementptr inbounds [5 x i32]* @switch.table6, i32 0, i32 %switch.tableidx +; CHECK: getelementptr inbounds [9 x i32], [9 x i32]* @switch.table.6, i32 0, i32 %switch.tableidx +} + +define i32 @unreachable_default(i32 %x) { +entry: + switch i32 %x, label %default [ + i32 0, label %bb0 + i32 1, label %bb1 + i32 2, label %bb2 + i32 3, label %bb3 + ] + +bb0: br label %return +bb1: br label %return +bb2: br label %return +bb3: br label %return +default: unreachable + +return: + %retval = phi i32 [ 42, %bb0 ], [ 52, %bb1 ], [ 1, %bb2 ], [ 2, %bb3 ] + ret i32 %retval + +; CHECK-LABEL: @unreachable_default( +; CHECK: entry: +; CHECK-NEXT: %switch.tableidx = sub i32 %x, 0 +; CHECK-NOT: icmp +; CHECK-NOT: br 1i +; CHECK-NEXT: %switch.gep = getelementptr inbounds [4 x i32], [4 x i32]* @switch.table.7, i32 0, i32 %switch.tableidx +; CHECK-NEXT: %switch.load = load i32, i32* %switch.gep +; CHECK-NEXT: ret i32 %switch.load } ; Don't create a table with illegal type @@ -967,10 +996,10 @@ sw.bb2: sw.default: br label %return return: - %retval.0 = phi i32* [ getelementptr inbounds ([3 x i32]* @dllimport_d, i32 0, i32 0), %sw.default ], - [ getelementptr inbounds ([3 x i32]* @dllimport_c, i32 0, i32 0), %sw.bb2 ], - [ getelementptr inbounds ([3 x i32]* @dllimport_b, i32 0, i32 0), %sw.bb1 ], - [ getelementptr inbounds ([3 x i32]* @dllimport_a, i32 0, i32 0), %entry ] + %retval.0 = phi i32* [ getelementptr inbounds ([3 x i32], [3 x i32]* @dllimport_d, i32 0, i32 0), %sw.default ], + [ getelementptr inbounds ([3 x i32], [3 x i32]* @dllimport_c, i32 0, i32 0), %sw.bb2 ], + [ getelementptr inbounds ([3 x i32], [3 x i32]* @dllimport_b, i32 0, i32 0), %sw.bb1 ], + [ getelementptr inbounds ([3 x i32], [3 x i32]* @dllimport_a, i32 0, i32 0), %entry ] ret i32* %retval.0 ; CHECK-LABEL: @dllimport( ; CHECK: switch i32 @@ -1244,3 +1273,32 @@ end: ; CHECK-LABEL: @pr20210 ; CHECK: switch i8 %x } + +; Make sure we do not crash due to trying to generate an unguarded +; lookup (since i3 can only hold values in the range of explicit +; values) and simultaneously trying to generate a branch to deal with +; the fact that we have holes in the range. +define i32 @covered_switch_with_bit_tests(i3) { +entry: + switch i3 %0, label %l6 [ + i3 -3, label %l5 + i3 -4, label %l5 + i3 3, label %l1 + i3 2, label %l1 + ] + +l1: br label %l2 + +l2: + %x = phi i32 [ 1, %l1 ], [ 2, %l5 ] + br label %l6 + +l5: br label %l2 + +l6: + %r = phi i32 [ %x, %l2 ], [ 0, %entry ] + ret i32 %r +; CHECK-LABEL: @covered_switch_with_bit_tests +; CHECK: entry +; CHECK-NEXT: switch +} diff --git a/test/Transforms/SimplifyCFG/attr-noduplicate.ll b/test/Transforms/SimplifyCFG/attr-noduplicate.ll index 523aa51bb84e..5f8456ba4054 100644 --- a/test/Transforms/SimplifyCFG/attr-noduplicate.ll +++ b/test/Transforms/SimplifyCFG/attr-noduplicate.ll @@ -8,8 +8,8 @@ ; CHECK-NOT: call void @barrier define void @noduplicate(i32 %cond, i32* %out) { entry: - %out1 = getelementptr i32* %out, i32 1 - %out2 = getelementptr i32* %out, i32 2 + %out1 = getelementptr i32, i32* %out, i32 1 + %out2 = getelementptr i32, i32* %out, i32 2 %cmp = icmp eq i32 %cond, 0 br i1 %cmp, label %if.then, label %if.end diff --git a/test/Transforms/SimplifyCFG/basictest.ll b/test/Transforms/SimplifyCFG/basictest.ll index 5de7cc5e31d5..d228499b2ec5 100644 --- a/test/Transforms/SimplifyCFG/basictest.ll +++ b/test/Transforms/SimplifyCFG/basictest.ll @@ -1,6 +1,7 @@ ; Test CFG simplify removal of branch instructions. ; ; RUN: opt < %s -simplifycfg -S | FileCheck %s +; RUN: opt < %s -passes=simplify-cfg -S | FileCheck %s define void @test1() { br label %1 @@ -49,7 +50,7 @@ define i8 @test6f() { ; CHECK: alloca i8, align 1 ; CHECK-NEXT: call i8 @test6g ; CHECK-NEXT: icmp eq i8 %tmp, 0 -; CHECK-NEXT: load i8* %r, align 1{{$}} +; CHECK-NEXT: load i8, i8* %r, align 1{{$}} bb0: %r = alloca i8, align 1 @@ -57,7 +58,7 @@ bb0: %tmp1 = icmp eq i8 %tmp, 0 br i1 %tmp1, label %bb2, label %bb1 bb1: - %tmp3 = load i8* %r, align 1, !range !2, !tbaa !1 + %tmp3 = load i8, i8* %r, align 1, !range !2, !tbaa !1 %tmp4 = icmp eq i8 %tmp3, 1 br i1 %tmp4, label %bb2, label %bb3 bb2: diff --git a/test/Transforms/SimplifyCFG/branch-fold-dbg.ll b/test/Transforms/SimplifyCFG/branch-fold-dbg.ll index f715a0cda93c..fac5b186e89d 100644 --- a/test/Transforms/SimplifyCFG/branch-fold-dbg.ll +++ b/test/Transforms/SimplifyCFG/branch-fold-dbg.ll @@ -24,7 +24,7 @@ BB2: ; preds = %BB1 ;CHECK-NEXT: icmp eq BB3: ; preds = %BB2 - %6 = getelementptr inbounds [5 x %0]* @0, i32 0, i32 %0, !dbg !6 + %6 = getelementptr inbounds [5 x %0], [5 x %0]* @0, i32 0, i32 %0, !dbg !6 call void @llvm.dbg.value(metadata %0* %6, i64 0, metadata !7, metadata !{}), !dbg !12 %7 = icmp eq %0* %6, null, !dbg !13 br i1 %7, label %BB5, label %BB4, !dbg !13 @@ -41,19 +41,19 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnon !llvm.dbg.sp = !{!0} -!0 = !{!"0x2e\00foo\00foo\00\00231\000\001\000\006\00256\000\000", !15, !1, !3, null, void (i32)* @foo, null, null, null} ; [ DW_TAG_subprogram ] [line 231] [def] [scope 0] [foo] -!1 = !{!"0x29", !15} ; [ DW_TAG_file_type ] -!2 = !{!"0x11\0012\00clang (trunk 129006)\001\00\000\00\000", !15, !4, !4, null, null, null} ; [ DW_TAG_compile_unit ] -!3 = !{!"0x15\00\000\000\000\000\000\000", !15, !1, null, !4, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!0 = !DISubprogram(name: "foo", line: 231, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, file: !15, scope: !1, type: !3, function: void (i32)* @foo) +!1 = !DIFile(filename: "a.c", directory: "/private/tmp") +!2 = !DICompileUnit(language: DW_LANG_C99, producer: "clang (trunk 129006)", isOptimized: true, emissionKind: 0, file: !15, enums: !4, retainedTypes: !4) +!3 = !DISubroutineType(types: !4) !4 = !{null} -!5 = !MDLocation(line: 131, column: 2, scope: !0) -!6 = !MDLocation(line: 134, column: 2, scope: !0) -!7 = !{!"0x100\00bar\00232\000", !8, !1, !9} ; [ DW_TAG_auto_variable ] -!8 = !{!"0xb\00231\001\003", !15, !0} ; [ DW_TAG_lexical_block ] -!9 = !{!"0xf\00\000\0032\0032\000\000", null, !2, !10} ; [ DW_TAG_pointer_type ] -!10 = !{!"0x26\00\000\000\000\000\000", null, !2, !11} ; [ DW_TAG_const_type ] -!11 = !{!"0x24\00unsigned int\000\0032\0032\000\000\007", null, !2} ; [ DW_TAG_base_type ] -!12 = !MDLocation(line: 232, column: 40, scope: !8) -!13 = !MDLocation(line: 234, column: 2, scope: !8) -!14 = !MDLocation(line: 274, column: 1, scope: !8) -!15 = !{!"a.c", !"/private/tmp"} +!5 = !DILocation(line: 131, column: 2, scope: !0) +!6 = !DILocation(line: 134, column: 2, scope: !0) +!7 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "bar", line: 232, scope: !8, file: !1, type: !9) +!8 = distinct !DILexicalBlock(line: 231, column: 1, file: !15, scope: !0) +!9 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 32, align: 32, scope: !2, baseType: !10) +!10 = !DIDerivedType(tag: DW_TAG_const_type, scope: !2, baseType: !11) +!11 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned) +!12 = !DILocation(line: 232, column: 40, scope: !8) +!13 = !DILocation(line: 234, column: 2, scope: !8) +!14 = !DILocation(line: 274, column: 1, scope: !8) +!15 = !DIFile(filename: "a.c", directory: "/private/tmp") diff --git a/test/Transforms/SimplifyCFG/branch-fold-threshold.ll b/test/Transforms/SimplifyCFG/branch-fold-threshold.ll index 878c0a4837ae..fad5fce1d4b0 100644 --- a/test/Transforms/SimplifyCFG/branch-fold-threshold.ll +++ b/test/Transforms/SimplifyCFG/branch-fold-threshold.ll @@ -19,7 +19,7 @@ lor.lhs.false: ; AGGRESSIVE-NOT: br i1 cond.false: - %0 = load i32* %input, align 4 + %0 = load i32, i32* %input, align 4 br label %cond.end cond.end: diff --git a/test/Transforms/SimplifyCFG/branch-phi-thread.ll b/test/Transforms/SimplifyCFG/branch-phi-thread.ll index c19ba69866b4..4c1b7e68e25f 100644 --- a/test/Transforms/SimplifyCFG/branch-phi-thread.ll +++ b/test/Transforms/SimplifyCFG/branch-phi-thread.ll @@ -51,7 +51,7 @@ E: br i1 %C, label %T, label %F T: ; preds = %A, %E call void @f3( ) - %XX = load i32* %AP ; <i32> [#uses=1] + %XX = load i32, i32* %AP ; <i32> [#uses=1] store i32 %XX, i32* %BP br i1 %C, label %B, label %A A: ; preds = %T diff --git a/test/Transforms/SimplifyCFG/clamp.ll b/test/Transforms/SimplifyCFG/clamp.ll new file mode 100644 index 000000000000..d21894a12699 --- /dev/null +++ b/test/Transforms/SimplifyCFG/clamp.ll @@ -0,0 +1,22 @@ +; RUN: opt < %s -simplifycfg -S | FileCheck %s + +define float @clamp(float %a, float %b, float %c) { +; CHECK-LABEL: @clamp +; CHECK: %cmp = fcmp ogt float %a, %c +; CHECK: %cmp1 = fcmp olt float %a, %b +; CHECK: %cond = select i1 %cmp1, float %b, float %a +; CHECK: %cond5 = select i1 %cmp, float %c, float %cond +; CHECK: ret float %cond5 +entry: + %cmp = fcmp ogt float %a, %c + br i1 %cmp, label %cond.end4, label %cond.false + +cond.false: ; preds = %entry + %cmp1 = fcmp olt float %a, %b + %cond = select i1 %cmp1, float %b, float %a + br label %cond.end4 + +cond.end4: ; preds = %entry, %cond.false + %cond5 = phi float [ %cond, %cond.false ], [ %c, %entry ] + ret float %cond5 +} diff --git a/test/Transforms/SimplifyCFG/common-dest-folding.ll b/test/Transforms/SimplifyCFG/common-dest-folding.ll index 0aa3b2c560a5..e3e27c706d1d 100644 --- a/test/Transforms/SimplifyCFG/common-dest-folding.ll +++ b/test/Transforms/SimplifyCFG/common-dest-folding.ll @@ -18,7 +18,7 @@ define i32 @foo(i32 %k, i32 %c1, i32 %c2) { br i1 %5, label %8, label %6 ; <label>:6 ; preds = %3 - %7 = tail call i32 (...)* @bar() nounwind + %7 = tail call i32 (...) @bar() nounwind br label %8 ; <label>:8 ; preds = %3, %0, %6 @@ -47,7 +47,7 @@ bb3: ; preds = %bb br i1 %tmp6, label %bb9, label %bb7 bb7: ; preds = %bb3 - %tmp8 = tail call i32 (...)* @bar() #1 + %tmp8 = tail call i32 (...) @bar() #1 br label %bb9 bb9: ; preds = %bb7, %bb3, %bb diff --git a/test/Transforms/SimplifyCFG/dbginfo.ll b/test/Transforms/SimplifyCFG/dbginfo.ll index 1a9f20ac871e..12aec91c6c55 100644 --- a/test/Transforms/SimplifyCFG/dbginfo.ll +++ b/test/Transforms/SimplifyCFG/dbginfo.ll @@ -58,7 +58,7 @@ entry: %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] call void @llvm.dbg.func.start({ }* bitcast (%llvm.dbg.subprogram.type* @llvm.dbg.subprogram947 to { }*)) store %struct.__false_type* %this, %struct.__false_type** %this_addr - %0 = load %struct.__false_type** %this_addr, align 4 ; <%struct.__false_type*> [#uses=1] + %0 = load %struct.__false_type*, %struct.__false_type** %this_addr, align 4 ; <%struct.__false_type*> [#uses=1] call void @_ZN9__gnu_cxx13new_allocatorIP5SceneED2Ev(%struct.__false_type* %0) nounwind br label %bb diff --git a/test/Transforms/SimplifyCFG/duplicate-landingpad.ll b/test/Transforms/SimplifyCFG/duplicate-landingpad.ll new file mode 100644 index 000000000000..54028774d20e --- /dev/null +++ b/test/Transforms/SimplifyCFG/duplicate-landingpad.ll @@ -0,0 +1,110 @@ +; RUN: opt < %s -simplifycfg -S | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" + +declare i32 @__gxx_personality_v0(...) +declare void @fn() + + +; CHECK-LABEL: @test1 +define void @test1() { +entry: +; CHECK-LABEL: entry: +; CHECK: to label %invoke2 unwind label %lpad2 + invoke void @fn() + to label %invoke2 unwind label %lpad1 + +invoke2: +; CHECK-LABEL: invoke2: +; CHECK: to label %invoke.cont unwind label %lpad2 + invoke void @fn() + to label %invoke.cont unwind label %lpad2 + +invoke.cont: + ret void + +lpad1: + %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 + cleanup + br label %shared_resume + +lpad2: +; CHECK-LABEL: lpad2: +; CHECK: landingpad { i8*, i32 } personality i32 (...)* @__gxx_personality_v0 +; CHECK-NEXT: cleanup +; CHECK-NEXT: call void @fn() +; CHECK-NEXT: ret void + %exn2 = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 + cleanup + br label %shared_resume + +shared_resume: + call void @fn() + ret void +} + +; Don't trigger if blocks aren't the same/empty +define void @neg1() { +; CHECK-LABEL: @neg1 +entry: +; CHECK-LABEL: entry: +; CHECK: to label %invoke2 unwind label %lpad1 + invoke void @fn() + to label %invoke2 unwind label %lpad1 + +invoke2: +; CHECK-LABEL: invoke2: +; CHECK: to label %invoke.cont unwind label %lpad2 + invoke void @fn() + to label %invoke.cont unwind label %lpad2 + +invoke.cont: + ret void + +lpad1: + %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 + filter [0 x i8*] zeroinitializer + call void @fn() + br label %shared_resume + +lpad2: + %exn2 = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 + cleanup + br label %shared_resume + +shared_resume: + call void @fn() + ret void +} + +; Should not trigger when the landing pads are not the exact same +define void @neg2() { +; CHECK-LABEL: @neg2 +entry: +; CHECK-LABEL: entry: +; CHECK: to label %invoke2 unwind label %lpad1 + invoke void @fn() + to label %invoke2 unwind label %lpad1 + +invoke2: +; CHECK-LABEL: invoke2: +; CHECK: to label %invoke.cont unwind label %lpad2 + invoke void @fn() + to label %invoke.cont unwind label %lpad2 + +invoke.cont: + ret void + +lpad1: + %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 + filter [0 x i8*] zeroinitializer + br label %shared_resume + +lpad2: + %exn2 = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 + cleanup + br label %shared_resume + +shared_resume: + call void @fn() + ret void +} diff --git a/test/Transforms/SimplifyCFG/hoist-common-code.ll b/test/Transforms/SimplifyCFG/hoist-common-code.ll index 5c83e2a3aa49..c1ca605cc206 100644 --- a/test/Transforms/SimplifyCFG/hoist-common-code.ll +++ b/test/Transforms/SimplifyCFG/hoist-common-code.ll @@ -6,12 +6,12 @@ define void @test(i1 %P, i32* %Q) { br i1 %P, label %T, label %F T: ; preds = %0 store i32 1, i32* %Q - %A = load i32* %Q ; <i32> [#uses=1] + %A = load i32, i32* %Q ; <i32> [#uses=1] call void @bar( i32 %A ) ret void F: ; preds = %0 store i32 1, i32* %Q - %B = load i32* %Q ; <i32> [#uses=1] + %B = load i32, i32* %Q ; <i32> [#uses=1] call void @bar( i32 %B ) ret void } diff --git a/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll b/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll index 869ce099d075..345cf6282e3c 100644 --- a/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll +++ b/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll @@ -1,21 +1,21 @@ ; RUN: opt -simplifycfg -S < %s | FileCheck %s define i32 @foo(i32 %i) nounwind ssp { - call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !6, metadata !{}), !dbg !7 - call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !9, metadata !{}), !dbg !11 + call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !6, metadata !DIExpression()), !dbg !7 + call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !9, metadata !DIExpression()), !dbg !11 %1 = icmp ne i32 %i, 0, !dbg !12 -;CHECK: call i32 (...)* @bar() +;CHECK: call i32 (...) @bar() ;CHECK-NEXT: llvm.dbg.value br i1 %1, label %2, label %4, !dbg !12 ; <label>:2 ; preds = %0 - %3 = call i32 (...)* @bar(), !dbg !13 - call void @llvm.dbg.value(metadata i32 %3, i64 0, metadata !9, metadata !{}), !dbg !13 + %3 = call i32 (...) @bar(), !dbg !13 + call void @llvm.dbg.value(metadata i32 %3, i64 0, metadata !9, metadata !DIExpression()), !dbg !13 br label %6, !dbg !15 ; <label>:4 ; preds = %0 - %5 = call i32 (...)* @bar(), !dbg !16 - call void @llvm.dbg.value(metadata i32 %5, i64 0, metadata !9, metadata !{}), !dbg !16 + %5 = call i32 (...) @bar(), !dbg !16 + call void @llvm.dbg.value(metadata i32 %5, i64 0, metadata !9, metadata !DIExpression()), !dbg !16 br label %6, !dbg !18 ; <label>:6 ; preds = %4, %2 @@ -32,25 +32,25 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnon !llvm.module.flags = !{!21} !llvm.dbg.sp = !{!0} -!0 = !{!"0x2e\00foo\00foo\00\002\000\001\000\006\00256\000\000", !20, !1, !3, null, i32 (i32)* @foo, null, null, null} ; [ DW_TAG_subprogram ] [line 2] [def] [scope 0] [foo] -!1 = !{!"0x29", !20} ; [ DW_TAG_file_type ] -!2 = !{!"0x11\0012\00clang\001\00\000\00\000", !20, !8, !8, null, null, null} ; [ DW_TAG_compile_unit ] -!3 = !{!"0x15\00\000\000\000\000\000\000", !20, !1, null, !4, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!0 = !DISubprogram(name: "foo", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, file: !20, scope: !1, type: !3, function: i32 (i32)* @foo) +!1 = !DIFile(filename: "b.c", directory: "/private/tmp") +!2 = !DICompileUnit(language: DW_LANG_C99, producer: "clang", isOptimized: true, emissionKind: 0, file: !20, enums: !8, retainedTypes: !8) +!3 = !DISubroutineType(types: !4) !4 = !{!5} -!5 = !{!"0x24\00int\000\0032\0032\000\000\005", null, !2} ; [ DW_TAG_base_type ] -!6 = !{!"0x101\00i\0016777218\000", !0, !1, !5} ; [ DW_TAG_arg_variable ] -!7 = !MDLocation(line: 2, column: 13, scope: !0) +!5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!6 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "i", line: 2, arg: 1, scope: !0, file: !1, type: !5) +!7 = !DILocation(line: 2, column: 13, scope: !0) !8 = !{i32 0} -!9 = !{!"0x100\00k\003\000", !10, !1, !5} ; [ DW_TAG_auto_variable ] -!10 = !{!"0xb\002\0016\000", !20, !0} ; [ DW_TAG_lexical_block ] -!11 = !MDLocation(line: 3, column: 12, scope: !10) -!12 = !MDLocation(line: 4, column: 3, scope: !10) -!13 = !MDLocation(line: 5, column: 5, scope: !14) -!14 = !{!"0xb\004\0010\001", !20, !10} ; [ DW_TAG_lexical_block ] -!15 = !MDLocation(line: 6, column: 3, scope: !14) -!16 = !MDLocation(line: 7, column: 5, scope: !17) -!17 = !{!"0xb\006\0010\002", !20, !10} ; [ DW_TAG_lexical_block ] -!18 = !MDLocation(line: 8, column: 3, scope: !17) -!19 = !MDLocation(line: 9, column: 3, scope: !10) -!20 = !{!"b.c", !"/private/tmp"} -!21 = !{i32 1, !"Debug Info Version", i32 2} +!9 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "k", line: 3, scope: !10, file: !1, type: !5) +!10 = distinct !DILexicalBlock(line: 2, column: 16, file: !20, scope: !0) +!11 = !DILocation(line: 3, column: 12, scope: !10) +!12 = !DILocation(line: 4, column: 3, scope: !10) +!13 = !DILocation(line: 5, column: 5, scope: !14) +!14 = distinct !DILexicalBlock(line: 4, column: 10, file: !20, scope: !10) +!15 = !DILocation(line: 6, column: 3, scope: !14) +!16 = !DILocation(line: 7, column: 5, scope: !17) +!17 = distinct !DILexicalBlock(line: 6, column: 10, file: !20, scope: !10) +!18 = !DILocation(line: 8, column: 3, scope: !17) +!19 = !DILocation(line: 9, column: 3, scope: !10) +!20 = !DIFile(filename: "b.c", directory: "/private/tmp") +!21 = !{i32 1, !"Debug Info Version", i32 3} diff --git a/test/Transforms/SimplifyCFG/hoist-with-range.ll b/test/Transforms/SimplifyCFG/hoist-with-range.ll index 7ca3ff247dc8..0a2b28267ef1 100644 --- a/test/Transforms/SimplifyCFG/hoist-with-range.ll +++ b/test/Transforms/SimplifyCFG/hoist-with-range.ll @@ -2,15 +2,15 @@ define void @foo(i1 %c, i8* %p) { ; CHECK: if: -; CHECK-NEXT: load i8* %p, !range !0 +; CHECK-NEXT: load i8, i8* %p, !range !0 ; CHECK: !0 = !{i8 0, i8 1, i8 3, i8 5} if: br i1 %c, label %then, label %else then: - %t = load i8* %p, !range !0 + %t = load i8, i8* %p, !range !0 br label %out else: - %e = load i8* %p, !range !1 + %e = load i8, i8* %p, !range !1 br label %out out: ret void diff --git a/test/Transforms/SimplifyCFG/indirectbr.ll b/test/Transforms/SimplifyCFG/indirectbr.ll index d0020d001b03..67e23d2fe935 100644 --- a/test/Transforms/SimplifyCFG/indirectbr.ll +++ b/test/Transforms/SimplifyCFG/indirectbr.ll @@ -17,7 +17,7 @@ entry: store i8* blockaddress(@indbrtest0, %BB1), i8** %P store i8* blockaddress(@indbrtest0, %BB2), i8** %P call void @foo() - %t = load i8** %Q + %t = load i8*, i8** %Q indirectbr i8* %t, [label %BB0, label %BB1, label %BB2, label %BB0, label %BB1, label %BB2] BB0: call void @A() @@ -42,7 +42,7 @@ define void @indbrtest1(i8** %P, i8** %Q) { entry: store i8* blockaddress(@indbrtest1, %BB0), i8** %P call void @foo() - %t = load i8** %Q + %t = load i8*, i8** %Q indirectbr i8* %t, [label %BB0, label %BB0] BB0: call void @A() @@ -192,8 +192,8 @@ escape-string.top: xlab8x: ; preds = %xlab5x %xvaluex = call i32 @xselectorx() - %xblkx.x = getelementptr [9 x i8*]* @xblkx.bbs, i32 0, i32 %xvaluex - %xblkx.load = load i8** %xblkx.x + %xblkx.x = getelementptr [9 x i8*], [9 x i8*]* @xblkx.bbs, i32 0, i32 %xvaluex + %xblkx.load = load i8*, i8** %xblkx.x indirectbr i8* %xblkx.load, [label %xblkx.begin, label %xblkx.begin3, label %xblkx.begin4, label %xblkx.begin5, label %xblkx.begin6, label %xblkx.begin7, label %xblkx.begin8, label %xblkx.begin9, label %xblkx.end] xblkx.begin: diff --git a/test/Transforms/SimplifyCFG/iterative-simplify.ll b/test/Transforms/SimplifyCFG/iterative-simplify.ll index a39741105764..60728b9a9578 100644 --- a/test/Transforms/SimplifyCFG/iterative-simplify.ll +++ b/test/Transforms/SimplifyCFG/iterative-simplify.ll @@ -17,13 +17,13 @@ cond_true: ; preds = %entry br label %bb bb: ; preds = %cond_next, %cond_true - %tmp = load i32* %z ; <i32> [#uses=1] + %tmp = load i32, i32* %z ; <i32> [#uses=1] %tmp1 = sub i32 %tmp, 16384 ; <i32> [#uses=1] store i32 %tmp1, i32* %z - %tmp2 = load i32* %i ; <i32> [#uses=1] + %tmp2 = load i32, i32* %i ; <i32> [#uses=1] %tmp3 = add i32 %tmp2, 1 ; <i32> [#uses=1] store i32 %tmp3, i32* %i - %tmp4 = load i32* %i ; <i32> [#uses=1] + %tmp4 = load i32, i32* %i ; <i32> [#uses=1] %tmp5 = icmp sgt i32 %tmp4, 262144 ; <i1> [#uses=1] %tmp56 = zext i1 %tmp5 to i8 ; <i8> [#uses=1] %toBool7 = icmp ne i8 %tmp56, 0 ; <i1> [#uses=1] @@ -34,7 +34,7 @@ cond_true8: ; preds = %bb unreachable cond_next: ; preds = %bb - %tmp9 = load i32* %z ; <i32> [#uses=1] + %tmp9 = load i32, i32* %z ; <i32> [#uses=1] %tmp10 = icmp ne i32 %tmp9, 0 ; <i1> [#uses=1] %tmp1011 = zext i1 %tmp10 to i8 ; <i8> [#uses=1] %toBool12 = icmp ne i8 %tmp1011, 0 ; <i1> [#uses=1] @@ -53,13 +53,13 @@ cond_true15: ; preds = %cond_false br label %bb17 bb17: ; preds = %cond_next27, %cond_true15 - %tmp18 = load i32* %z16 ; <i32> [#uses=1] + %tmp18 = load i32, i32* %z16 ; <i32> [#uses=1] %tmp19 = sub i32 %tmp18, 16384 ; <i32> [#uses=1] store i32 %tmp19, i32* %z16 - %tmp20 = load i32* %i ; <i32> [#uses=1] + %tmp20 = load i32, i32* %i ; <i32> [#uses=1] %tmp21 = add i32 %tmp20, 1 ; <i32> [#uses=1] store i32 %tmp21, i32* %i - %tmp22 = load i32* %i ; <i32> [#uses=1] + %tmp22 = load i32, i32* %i ; <i32> [#uses=1] %tmp23 = icmp sgt i32 %tmp22, 262144 ; <i1> [#uses=1] %tmp2324 = zext i1 %tmp23 to i8 ; <i8> [#uses=1] %toBool25 = icmp ne i8 %tmp2324, 0 ; <i1> [#uses=1] @@ -70,7 +70,7 @@ cond_true26: ; preds = %bb17 unreachable cond_next27: ; preds = %bb17 - %tmp28 = load i32* %z16 ; <i32> [#uses=1] + %tmp28 = load i32, i32* %z16 ; <i32> [#uses=1] %tmp29 = icmp ne i32 %tmp28, 0 ; <i1> [#uses=1] %tmp2930 = zext i1 %tmp29 to i8 ; <i8> [#uses=1] %toBool31 = icmp ne i8 %tmp2930, 0 ; <i1> [#uses=1] @@ -91,7 +91,7 @@ cond_next35: ; preds = %cond_next34 br label %return return: ; preds = %cond_next35 - %retval36 = load i32* %retval ; <i32> [#uses=1] + %retval36 = load i32, i32* %retval ; <i32> [#uses=1] ret i32 %retval36 } diff --git a/test/Transforms/SimplifyCFG/multiple-phis.ll b/test/Transforms/SimplifyCFG/multiple-phis.ll index 78454232461a..a6eef09ae646 100644 --- a/test/Transforms/SimplifyCFG/multiple-phis.ll +++ b/test/Transforms/SimplifyCFG/multiple-phis.ll @@ -22,8 +22,8 @@ while.body: ; preds = %while.cond %add = add i32 %low.0, %high.addr.0 %div = udiv i32 %add, 2 %idxprom = zext i32 %div to i64 - %arrayidx = getelementptr inbounds i32* %r, i64 %idxprom - %0 = load i32* %arrayidx + %arrayidx = getelementptr inbounds i32, i32* %r, i64 %idxprom + %0 = load i32, i32* %arrayidx %cmp1 = icmp ult i32 %k, %0 br i1 %cmp1, label %if.then, label %if.else diff --git a/test/Transforms/SimplifyCFG/no_speculative_loads_with_tsan.ll b/test/Transforms/SimplifyCFG/no_speculative_loads_with_tsan.ll index b388cc5830f4..4792e9565b2d 100644 --- a/test/Transforms/SimplifyCFG/no_speculative_loads_with_tsan.ll +++ b/test/Transforms/SimplifyCFG/no_speculative_loads_with_tsan.ll @@ -8,7 +8,7 @@ entry: br i1 %tobool, label %return, label %if.then if.then: ; preds = %entry - %0 = load i32* @g, align 4 + %0 = load i32, i32* @g, align 4 br label %return return: ; preds = %entry, %if.then @@ -26,7 +26,7 @@ entry: br i1 %tobool, label %return, label %if.then if.then: ; preds = %entry - %0 = load i32* @g, align 4 + %0 = load i32, i32* @g, align 4 br label %return return: ; preds = %entry, %if.then @@ -34,7 +34,7 @@ return: ; preds = %entry, %if.then ret i32 %retval ; CHECK-LABEL: @TestTsan ; CHECK: br i1 -; CHECK: load i32* @g +; CHECK: load i32, i32* @g ; CHECK: br label ; CHECK: ret i32 } diff --git a/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll b/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll index f34aec525df8..c0f0046a1d2c 100644 --- a/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll +++ b/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll @@ -21,7 +21,7 @@ if.then4: ; preds = %if.else if.end7: ; preds = %if.else, %if.then4, %if.then %x.0 = phi i32* [ %a, %if.then ], [ %c, %if.then4 ], [ null, %if.else ] - %tmp9 = load i32* %x.0 + %tmp9 = load i32, i32* %x.0 ret i32 %tmp9 ; CHECK-LABEL: @test1( @@ -50,7 +50,7 @@ if.then4: ; preds = %if.else if.end7: ; preds = %if.else, %if.then4, %if.then %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ] - %tmp9 = load i32* %x.0 + %tmp9 = load i32, i32* %x.0 ret i32 %tmp9 ; CHECK-LABEL: @test2( ; CHECK: if.else: @@ -79,7 +79,7 @@ if.then4: ; preds = %if.else if.end7: ; preds = %if.else, %if.then4, %if.then %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ] tail call void @bar() nounwind - %tmp9 = load i32* %x.0 + %tmp9 = load i32, i32* %x.0 ret i32 %tmp9 ; CHECK-LABEL: @test3( ; CHECK: if.end7: @@ -105,8 +105,8 @@ if.then4: ; preds = %if.else if.end7: ; preds = %if.else, %if.then4, %if.then %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ] - %gep = getelementptr i32* %x.0, i32 10 - %tmp9 = load i32* %gep + %gep = getelementptr i32, i32* %x.0, i32 10 + %tmp9 = load i32, i32* %gep %tmp10 = or i32 %tmp9, 1 store i32 %tmp10, i32* %gep ret i32 %tmp9 diff --git a/test/Transforms/SimplifyCFG/preserve-branchweights.ll b/test/Transforms/SimplifyCFG/preserve-branchweights.ll index 7802a0593574..ae1794b1c61a 100644 --- a/test/Transforms/SimplifyCFG/preserve-branchweights.ll +++ b/test/Transforms/SimplifyCFG/preserve-branchweights.ll @@ -353,7 +353,7 @@ for.cond2: %tobool = icmp eq i32 %bit.0, 0 br i1 %tobool, label %for.exit, label %for.body3, !prof !10 for.body3: - %v3 = load i32* @max_regno, align 4 + %v3 = load i32, i32* @max_regno, align 4 %cmp4 = icmp eq i32 %i.1, %v3 br i1 %cmp4, label %for.exit, label %for.inc, !prof !11 for.inc: diff --git a/test/Transforms/SimplifyCFG/seh-nounwind.ll b/test/Transforms/SimplifyCFG/seh-nounwind.ll new file mode 100644 index 000000000000..3845e3198909 --- /dev/null +++ b/test/Transforms/SimplifyCFG/seh-nounwind.ll @@ -0,0 +1,31 @@ +; RUN: opt -S -simplifycfg < %s | FileCheck %s + +; Don't remove invokes of nounwind functions if the personality handles async +; exceptions. The @div function in this test can fault, even though it can't +; throw a synchronous exception. + +define i32 @div(i32 %n, i32 %d) nounwind { +entry: + %div = sdiv i32 %n, %d + ret i32 %div +} + +define i32 @main() nounwind { +entry: + %call = invoke i32 @div(i32 10, i32 0) + to label %__try.cont unwind label %lpad + +lpad: + %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) + catch i8* null + br label %__try.cont + +__try.cont: + %retval.0 = phi i32 [ %call, %entry ], [ 0, %lpad ] + ret i32 %retval.0 +} + +; CHECK-LABEL: define i32 @main() +; CHECK: invoke i32 @div(i32 10, i32 0) + +declare i32 @__C_specific_handler(...) diff --git a/test/Transforms/SimplifyCFG/select-gep.ll b/test/Transforms/SimplifyCFG/select-gep.ll index 96c214cbc81e..f2bc5abbf738 100644 --- a/test/Transforms/SimplifyCFG/select-gep.ll +++ b/test/Transforms/SimplifyCFG/select-gep.ll @@ -1,40 +1,21 @@ ; RUN: opt -S -simplifycfg < %s | FileCheck %s -define i8* @test1(i8* %x, i64 %y) nounwind { -entry: - %tmp1 = load i8* %x, align 1 - %cmp = icmp eq i8 %tmp1, 47 - br i1 %cmp, label %if.then, label %if.end - -if.then: - %incdec.ptr = getelementptr inbounds i8* %x, i64 %y - br label %if.end - -if.end: - %x.addr = phi i8* [ %incdec.ptr, %if.then ], [ %x, %entry ] - ret i8* %x.addr - -; CHECK-LABEL: @test1( -; CHECK-NOT: select -; CHECK: ret i8* %x.addr -} - %ST = type { i8, i8 } -define i8* @test2(%ST* %x, i8* %y) nounwind { +define i8* @test1(%ST* %x, i8* %y) nounwind { entry: %cmp = icmp eq %ST* %x, null br i1 %cmp, label %if.then, label %if.end if.then: - %incdec.ptr = getelementptr %ST* %x, i32 0, i32 1 + %incdec.ptr = getelementptr %ST, %ST* %x, i32 0, i32 1 br label %if.end if.end: %x.addr = phi i8* [ %incdec.ptr, %if.then ], [ %y, %entry ] ret i8* %x.addr -; CHECK-LABEL: @test2( +; CHECK-LABEL: @test1( ; CHECK: %incdec.ptr.y = select i1 %cmp, i8* %incdec.ptr, i8* %y ; CHECK: ret i8* %incdec.ptr.y } diff --git a/test/Transforms/SimplifyCFG/speculate-store.ll b/test/Transforms/SimplifyCFG/speculate-store.ll index e241901a8789..c1ac7bcea249 100644 --- a/test/Transforms/SimplifyCFG/speculate-store.ll +++ b/test/Transforms/SimplifyCFG/speculate-store.ll @@ -2,15 +2,15 @@ define void @ifconvertstore(i32 %m, i32* %A, i32* %B, i32 %C, i32 %D) { entry: - %arrayidx = getelementptr inbounds i32* %B, i64 0 - %0 = load i32* %arrayidx, align 4 + %arrayidx = getelementptr inbounds i32, i32* %B, i64 0 + %0 = load i32, i32* %arrayidx, align 4 %add = add nsw i32 %0, %C - %arrayidx2 = getelementptr inbounds i32* %A, i64 0 + %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 0 ; First store to the location. store i32 %add, i32* %arrayidx2, align 4 - %arrayidx4 = getelementptr inbounds i32* %B, i64 1 - %1 = load i32* %arrayidx4, align 4 + %arrayidx4 = getelementptr inbounds i32, i32* %B, i64 1 + %1 = load i32, i32* %arrayidx4, align 4 %add5 = add nsw i32 %1, %D %cmp6 = icmp sgt i32 %add5, %C br i1 %cmp6, label %if.then, label %ret.end @@ -30,15 +30,15 @@ ret.end: define void @noifconvertstore1(i32 %m, i32* %A, i32* %B, i32 %C, i32 %D) { entry: - %arrayidx = getelementptr inbounds i32* %B, i64 0 - %0 = load i32* %arrayidx, align 4 + %arrayidx = getelementptr inbounds i32, i32* %B, i64 0 + %0 = load i32, i32* %arrayidx, align 4 %add = add nsw i32 %0, %C - %arrayidx2 = getelementptr inbounds i32* %A, i64 0 + %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 0 ; Store to a different location. store i32 %add, i32* %arrayidx, align 4 - %arrayidx4 = getelementptr inbounds i32* %B, i64 1 - %1 = load i32* %arrayidx4, align 4 + %arrayidx4 = getelementptr inbounds i32, i32* %B, i64 1 + %1 = load i32, i32* %arrayidx4, align 4 %add5 = add nsw i32 %1, %D %cmp6 = icmp sgt i32 %add5, %C br i1 %cmp6, label %if.then, label %ret.end @@ -57,16 +57,16 @@ declare void @unknown_fun() define void @noifconvertstore2(i32 %m, i32* %A, i32* %B, i32 %C, i32 %D) { entry: - %arrayidx = getelementptr inbounds i32* %B, i64 0 - %0 = load i32* %arrayidx, align 4 + %arrayidx = getelementptr inbounds i32, i32* %B, i64 0 + %0 = load i32, i32* %arrayidx, align 4 %add = add nsw i32 %0, %C - %arrayidx2 = getelementptr inbounds i32* %A, i64 0 + %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 0 ; First store to the location. store i32 %add, i32* %arrayidx2, align 4 call void @unknown_fun() - %arrayidx4 = getelementptr inbounds i32* %B, i64 1 - %1 = load i32* %arrayidx4, align 4 + %arrayidx4 = getelementptr inbounds i32, i32* %B, i64 1 + %1 = load i32, i32* %arrayidx4, align 4 %add5 = add nsw i32 %1, %D %cmp6 = icmp sgt i32 %add5, %C br i1 %cmp6, label %if.then, label %ret.end @@ -83,15 +83,15 @@ ret.end: define void @noifconvertstore_volatile(i32 %m, i32* %A, i32* %B, i32 %C, i32 %D) { entry: - %arrayidx = getelementptr inbounds i32* %B, i64 0 - %0 = load i32* %arrayidx, align 4 + %arrayidx = getelementptr inbounds i32, i32* %B, i64 0 + %0 = load i32, i32* %arrayidx, align 4 %add = add nsw i32 %0, %C - %arrayidx2 = getelementptr inbounds i32* %A, i64 0 + %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 0 ; First store to the location. store i32 %add, i32* %arrayidx2, align 4 - %arrayidx4 = getelementptr inbounds i32* %B, i64 1 - %1 = load i32* %arrayidx4, align 4 + %arrayidx4 = getelementptr inbounds i32, i32* %B, i64 1 + %1 = load i32, i32* %arrayidx4, align 4 %add5 = add nsw i32 %1, %D %cmp6 = icmp sgt i32 %add5, %C br i1 %cmp6, label %if.then, label %ret.end diff --git a/test/Transforms/SimplifyCFG/speculate-with-offset.ll b/test/Transforms/SimplifyCFG/speculate-with-offset.ll index 64fed85c795c..65ebb5c2c3f6 100644 --- a/test/Transforms/SimplifyCFG/speculate-with-offset.ll +++ b/test/Transforms/SimplifyCFG/speculate-with-offset.ll @@ -9,7 +9,7 @@ define void @yes(i1 %c) nounwind { entry: %a = alloca [4 x i64*], align 8 - %__a.addr = getelementptr [4 x i64*]* %a, i64 0, i64 3 + %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 0, i64 3 call void @frob(i64** %__a.addr) br i1 %c, label %if.then, label %if.end @@ -17,7 +17,7 @@ if.then: ; preds = %entry br label %return if.end: ; preds = %entry - %tmp5 = load i64** %__a.addr, align 8 + %tmp5 = load i64*, i64** %__a.addr, align 8 br label %return return: ; preds = %if.end, %if.then @@ -31,7 +31,7 @@ return: ; preds = %if.end, %if.then define void @no0(i1 %c) nounwind { entry: %a = alloca [4 x i64*], align 8 - %__a.addr = getelementptr [4 x i64*]* %a, i64 0, i64 4 + %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 0, i64 4 call void @frob(i64** %__a.addr) br i1 %c, label %if.then, label %if.end @@ -39,7 +39,7 @@ if.then: ; preds = %entry br label %return if.end: ; preds = %entry - %tmp5 = load i64** %__a.addr, align 8 + %tmp5 = load i64*, i64** %__a.addr, align 8 br label %return return: ; preds = %if.end, %if.then @@ -53,7 +53,7 @@ return: ; preds = %if.end, %if.then define void @no1(i1 %c, i64 %n) nounwind { entry: %a = alloca [4 x i64*], align 8 - %__a.addr = getelementptr [4 x i64*]* %a, i64 0, i64 %n + %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 0, i64 %n call void @frob(i64** %__a.addr) br i1 %c, label %if.then, label %if.end @@ -61,7 +61,7 @@ if.then: ; preds = %entry br label %return if.end: ; preds = %entry - %tmp5 = load i64** %__a.addr, align 8 + %tmp5 = load i64*, i64** %__a.addr, align 8 br label %return return: ; preds = %if.end, %if.then @@ -75,7 +75,7 @@ return: ; preds = %if.end, %if.then define void @no2(i1 %c, i64 %n) nounwind { entry: %a = alloca [4 x i64*], align 8 - %__a.addr = getelementptr [4 x i64*]* %a, i64 1, i64 0 + %__a.addr = getelementptr [4 x i64*], [4 x i64*]* %a, i64 1, i64 0 call void @frob(i64** %__a.addr) br i1 %c, label %if.then, label %if.end @@ -83,7 +83,7 @@ if.then: ; preds = %entry br label %return if.end: ; preds = %entry - %tmp5 = load i64** %__a.addr, align 8 + %tmp5 = load i64*, i64** %__a.addr, align 8 br label %return return: ; preds = %if.end, %if.then diff --git a/test/Transforms/SimplifyCFG/switch-range-to-icmp.ll b/test/Transforms/SimplifyCFG/switch-range-to-icmp.ll index 8bf2b04520b9..a109b317c732 100644 --- a/test/Transforms/SimplifyCFG/switch-range-to-icmp.ll +++ b/test/Transforms/SimplifyCFG/switch-range-to-icmp.ll @@ -48,3 +48,30 @@ b: %1 = call i32 @f(i32 1) ret i32 %1 } + + +define i32 @unreachable2(i32 %x) { +; CHECK-LABEL: @unreachable2 +; CHECK: x.off = add i32 %x, -5 +; CHECK: %switch = icmp ult i32 %x.off, 3 +; CHECK: br i1 %switch, label %a, label %b + +entry: + ; Note: folding the most popular case destination into the default + ; would prevent switch-to-icmp here. + switch i32 %x, label %unreachable [ + i32 5, label %a + i32 6, label %a + i32 7, label %a + i32 10, label %b + i32 20, label %b + ] +unreachable: + unreachable +a: + %0 = call i32 @f(i32 0) + ret i32 %0 +b: + %1 = call i32 @f(i32 1) + ret i32 %1 +} diff --git a/test/Transforms/SimplifyCFG/switch-to-select-multiple-edge-per-block-phi.ll b/test/Transforms/SimplifyCFG/switch-to-select-multiple-edge-per-block-phi.ll index ddf5d1f06ce7..f5359b5b2b32 100644 --- a/test/Transforms/SimplifyCFG/switch-to-select-multiple-edge-per-block-phi.ll +++ b/test/Transforms/SimplifyCFG/switch-to-select-multiple-edge-per-block-phi.ll @@ -20,12 +20,12 @@ define i32 @fn1() { ; CHECK: %switch.selectcmp1 = icmp eq i32 %1, 5 ; CHECK: %switch.select2 = select i1 %switch.selectcmp1, i32 5, i32 %switch.select entry: - %0 = load i32* @b, align 4 + %0 = load i32, i32* @b, align 4 %tobool = icmp eq i32 %0, 0 br i1 %tobool, label %if.end3, label %if.then if.then: - %1 = load i32* @a, align 4 + %1 = load i32, i32* @a, align 4 switch i32 %1, label %if.end3 [ i32 5, label %return i32 0, label %return diff --git a/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll b/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll index 69f97e5f9f9f..f4d171ad2b18 100644 --- a/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll +++ b/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll @@ -35,38 +35,3 @@ return: %retval.0 = phi i32 [ 4, %sw.epilog ], [ 2, %sw.bb1 ], [ 10, %sw.bb ] ret i32 %retval.0 } - -; int foo1_without_default(int a) { -; switch(a) { -; case 10: -; return 10; -; case 20: -; return 2; -; } -; __builtin_unreachable(); -; } - -define i32 @foo1_without_default(i32 %a) { -; CHECK-LABEL: @foo1_without_default -; CHECK: %switch.selectcmp = icmp eq i32 %a, 10 -; CHECK-NEXT: %switch.select = select i1 %switch.selectcmp, i32 10, i32 2 -; CHECK-NOT: %switch.selectcmp1 -entry: - switch i32 %a, label %sw.epilog [ - i32 10, label %sw.bb - i32 20, label %sw.bb1 - ] - -sw.bb: - br label %return - -sw.bb1: - br label %return - -sw.epilog: - unreachable - -return: - %retval.0 = phi i32 [ 2, %sw.bb1 ], [ 10, %sw.bb ] - ret i32 %retval.0 -} diff --git a/test/Transforms/SimplifyCFG/switch_create.ll b/test/Transforms/SimplifyCFG/switch_create.ll index e1e91570300c..490b7513a944 100644 --- a/test/Transforms/SimplifyCFG/switch_create.ll +++ b/test/Transforms/SimplifyCFG/switch_create.ll @@ -154,8 +154,8 @@ lor.end: ; preds = %entry, %entry, %ent define i1 @test6({ i32, i32 }* %I) { entry: - %tmp.1.i = getelementptr { i32, i32 }* %I, i64 0, i32 1 ; <i32*> [#uses=1] - %tmp.2.i = load i32* %tmp.1.i ; <i32> [#uses=6] + %tmp.1.i = getelementptr { i32, i32 }, { i32, i32 }* %I, i64 0, i32 1 ; <i32*> [#uses=1] + %tmp.2.i = load i32, i32* %tmp.1.i ; <i32> [#uses=6] %tmp.2 = icmp eq i32 %tmp.2.i, 14 ; <i1> [#uses=1] br i1 %tmp.2, label %shortcirc_done.4, label %shortcirc_next.0 shortcirc_next.0: ; preds = %entry diff --git a/test/Transforms/SimplifyCFG/trap-debugloc.ll b/test/Transforms/SimplifyCFG/trap-debugloc.ll index 24a286fd9735..fedf6b172d75 100644 --- a/test/Transforms/SimplifyCFG/trap-debugloc.ll +++ b/test/Transforms/SimplifyCFG/trap-debugloc.ll @@ -11,14 +11,14 @@ define void @foo() nounwind ssp { !llvm.module.flags = !{!10} !llvm.dbg.sp = !{!0} -!0 = !{!"0x2e\00foo\00foo\00\003\000\001\000\006\000\000\000", !8, !1, !3, null, void ()* @foo, null, null, null} ; [ DW_TAG_subprogram ] [line 3] [def] [scope 0] [foo] -!1 = !{!"0x29", !8} ; [ DW_TAG_file_type ] -!2 = !{!"0x11\0012\00Apple clang version 3.0 (tags/Apple/clang-206.1) (based on LLVM 3.0svn)\001\00\000\00\000", !8, !4, !4, !9, null, null} ; [ DW_TAG_compile_unit ] -!3 = !{!"0x15\00\000\000\000\000\000\000", !8, !1, null, !4, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!0 = !DISubprogram(name: "foo", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, file: !8, scope: !1, type: !3, function: void ()* @foo) +!1 = !DIFile(filename: "foo.c", directory: "/private/tmp") +!2 = !DICompileUnit(language: DW_LANG_C99, producer: "Apple clang version 3.0 (tags/Apple/clang-206.1) (based on LLVM 3.0svn)", isOptimized: true, emissionKind: 0, file: !8, enums: !{}, retainedTypes: !{}, subprograms: !9) +!3 = !DISubroutineType(types: !4) !4 = !{null} -!5 = !MDLocation(line: 4, column: 2, scope: !6) -!6 = !{!"0xb\003\0012\000", !8, !0} ; [ DW_TAG_lexical_block ] -!7 = !MDLocation(line: 5, column: 1, scope: !6) -!8 = !{!"foo.c", !"/private/tmp"} +!5 = !DILocation(line: 4, column: 2, scope: !6) +!6 = distinct !DILexicalBlock(line: 3, column: 12, file: !8, scope: !0) +!7 = !DILocation(line: 5, column: 1, scope: !6) +!8 = !DIFile(filename: "foo.c", directory: "/private/tmp") !9 = !{!0} -!10 = !{i32 1, !"Debug Info Version", i32 2} +!10 = !{i32 1, !"Debug Info Version", i32 3} diff --git a/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll b/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll index 5ae62af54581..5881367d9610 100644 --- a/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll +++ b/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll @@ -11,7 +11,7 @@ entry: br i1 %0, label %bb, label %return bb: ; preds = %entry - %1 = load volatile i32* null + %1 = load volatile i32, i32* null unreachable br label %return diff --git a/test/Transforms/SimplifyCFG/trivial-throw.ll b/test/Transforms/SimplifyCFG/trivial-throw.ll deleted file mode 100644 index ca2b5693e600..000000000000 --- a/test/Transforms/SimplifyCFG/trivial-throw.ll +++ /dev/null @@ -1,77 +0,0 @@ -; RUN: opt -simplifycfg -S < %s | FileCheck %s -; <rdar://problem/13360379> - -@_ZTVN10__cxxabiv117__class_type_infoE = external global i8* -@_ZTS13TestException = linkonce_odr constant [16 x i8] c"13TestException\00" -@_ZTI13TestException = linkonce_odr unnamed_addr constant { i8*, i8* } { i8* bitcast (i8** getelementptr inbounds (i8** @_ZTVN10__cxxabiv117__class_type_infoE, i64 2) to i8*), i8* getelementptr inbounds ([16 x i8]* @_ZTS13TestException, i32 0, i32 0) } - -define void @throw(i32 %n) #0 { -entry: - %exception = call i8* @__cxa_allocate_exception(i64 1) #4 - call void @__cxa_throw(i8* %exception, i8* bitcast ({ i8*, i8* }* @_ZTI13TestException to i8*), i8* null) #2 - unreachable -} - -define void @func() #0 { -entry: -; CHECK: func() -; CHECK: invoke void @throw -; CHECK-NOT: call void @throw - invoke void @throw(i32 42) #0 - to label %exit unwind label %lpad - -lpad: - %tmp0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - cleanup - resume { i8*, i32 } %tmp0 - -exit: - invoke void @abort() #2 - to label %invoke.cont unwind label %lpad1 - -invoke.cont: - unreachable - -lpad1: - %tmp1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) - catch i8* bitcast ({ i8*, i8* }* @_ZTI13TestException to i8*) - %tmp2 = extractvalue { i8*, i32 } %tmp1, 1 - %tmp3 = call i32 @llvm.eh.typeid.for(i8* bitcast ({ i8*, i8* }* @_ZTI13TestException to i8*)) #4 - %matches = icmp eq i32 %tmp2, %tmp3 - br i1 %matches, label %catch, label %eh.resume - -catch: - ret void - -eh.resume: - resume { i8*, i32 } %tmp1 -} - -define linkonce_odr hidden void @__clang_call_terminate(i8*) #1 { - %2 = call i8* @__cxa_begin_catch(i8* %0) #4 - call void @_ZSt9terminatev() #5 - unreachable -} - -declare void @abort() #2 - -declare i32 @llvm.eh.typeid.for(i8*) #3 - -declare void @__cxa_end_catch() - -declare i8* @__cxa_allocate_exception(i64) - -declare i32 @__gxx_personality_v0(...) - -declare void @__cxa_throw(i8*, i8*, i8*) - -declare i8* @__cxa_begin_catch(i8*) - -declare void @_ZSt9terminatev() - -attributes #0 = { ssp uwtable } -attributes #1 = { noinline noreturn nounwind } -attributes #2 = { noreturn } -attributes #3 = { nounwind readnone } -attributes #4 = { nounwind } -attributes #5 = { noreturn nounwind } diff --git a/test/Transforms/SimplifyCFG/unreachable-blocks.ll b/test/Transforms/SimplifyCFG/unreachable-blocks.ll index 1df0eab6259f..87a64ad47c62 100644 --- a/test/Transforms/SimplifyCFG/unreachable-blocks.ll +++ b/test/Transforms/SimplifyCFG/unreachable-blocks.ll @@ -10,12 +10,12 @@ entry: while_block: ; preds = %and_if_cont2, %and_if_cont %newlen = sub i32 %newlen, 1 - %newptr = getelementptr i8* %newptr, i64 1 + %newptr = getelementptr i8, i8* %newptr, i64 1 %test = icmp sgt i32 %newlen, 0 br i1 %test, label %and_if1, label %and_if_cont2 and_if1: ; preds = %while_block - %char = load i8* %newptr + %char = load i8, i8* %newptr %test2 = icmp ule i8 %char, 32 br label %and_if_cont2 diff --git a/test/Transforms/SimplifyCFG/volatile-phioper.ll b/test/Transforms/SimplifyCFG/volatile-phioper.ll index 6367451433c1..c366d059d334 100644 --- a/test/Transforms/SimplifyCFG/volatile-phioper.ll +++ b/test/Transforms/SimplifyCFG/volatile-phioper.ll @@ -17,19 +17,19 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 define void @test(i8** nocapture %PeiServices) #0 { entry: - %call = tail call i32 (...)* @Trace() #2 + %call = tail call i32 (...) @Trace() #2 %tobool = icmp eq i32 %call, 0 br i1 %tobool, label %while.body, label %if.then if.then: ; preds = %entry - %call1 = tail call i32 (...)* @Trace() #2 + %call1 = tail call i32 (...) @Trace() #2 br label %while.body while.body: ; preds = %entry, %if.then, %while.body %Addr.017 = phi i8* [ %incdec.ptr, %while.body ], [ null, %if.then ], [ null, %entry ] %x.016 = phi i8 [ %inc, %while.body ], [ 0, %if.then ], [ 0, %entry ] %inc = add i8 %x.016, 1 - %incdec.ptr = getelementptr inbounds i8* %Addr.017, i64 1 + %incdec.ptr = getelementptr inbounds i8, i8* %Addr.017, i64 1 store volatile i8 %x.016, i8* %Addr.017, align 1 %0 = ptrtoint i8* %incdec.ptr to i64 %1 = trunc i64 %0 to i32 |
