diff options
Diffstat (limited to 'llvm/test/Transforms/IndVarsSimplify')
33 files changed, 1186 insertions, 0 deletions
diff --git a/llvm/test/Transforms/IndVarsSimplify/.cvsignore b/llvm/test/Transforms/IndVarsSimplify/.cvsignore new file mode 100644 index 00000000000..7f2443f2f31 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/.cvsignore @@ -0,0 +1,3 @@ +Output +*.log +*.sum diff --git a/llvm/test/Transforms/IndVarsSimplify/2002-09-09-PointerIndVar.ll b/llvm/test/Transforms/IndVarsSimplify/2002-09-09-PointerIndVar.ll new file mode 100644 index 00000000000..4c80e4851f4 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2002-09-09-PointerIndVar.ll @@ -0,0 +1,16 @@ +; Induction variable pass is doing bad things with pointer induction vars, +; trying to do arithmetic on them directly. +; +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars +; +void %test(int %A, uint %S, sbyte* %S) { + + br label %Loop +Loop: + %PIV = phi sbyte* [%S, %0], [%PIVNext, %Loop] + + %PIV = cast sbyte* %PIV to ulong + %PIVNext = add ulong %PIV, 8 + %PIVNext = cast ulong %PIVNext to sbyte* + br label %Loop +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2003-04-16-ExprAnalysis.ll b/llvm/test/Transforms/IndVarsSimplify/2003-04-16-ExprAnalysis.ll new file mode 100644 index 00000000000..2f198255ebf --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2003-04-16-ExprAnalysis.ll @@ -0,0 +1,14 @@ +; This is a test case for the expression analysis code, not really indvars. +; It was assuming any constant of int type was a ConstantInteger. +; +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars + +%X = global int 7 + +void %test(int %A) { + br label %Loop +Loop: + %IV = phi int [%A, %0], [%IVNext, %Loop] + %IVNext = add int %IV, cast (int* %X to int) + br label %Loop +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2003-09-12-MultiplePred.ll b/llvm/test/Transforms/IndVarsSimplify/2003-09-12-MultiplePred.ll new file mode 100644 index 00000000000..ea1e5854904 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2003-09-12-MultiplePred.ll @@ -0,0 +1,12 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep indvar + +int %test() { + br bool true, label %LoopHead, label %LoopHead + +LoopHead: + %A = phi int [7, %0], [7, %0], [%B, %LoopHead] + %B = add int %A, 1 + br bool false, label %LoopHead, label %Out +Out: + ret int %B +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2003-09-23-NotAtTop.ll b/llvm/test/Transforms/IndVarsSimplify/2003-09-23-NotAtTop.ll new file mode 100644 index 00000000000..d715f688f19 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2003-09-23-NotAtTop.ll @@ -0,0 +1,16 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | %prcontext Loop: 1 | grep %indvar + +; The indvar simplification code should ensure that the first PHI in the block +; is the canonical one! + +int %test() { + br label %Loop +Loop: + %NonIndvar = phi int [200, %0], [%NonIndvarNext, %Loop] + %Canonical = phi int [0, %0], [%CanonicalNext, %Loop] + + %NonIndvarNext = div int %NonIndvar, 2 + %CanonicalNext = add int %Canonical, 1 + br label %Loop +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/2003-12-10-IndVarDeadCode.ll b/llvm/test/Transforms/IndVarsSimplify/2003-12-10-IndVarDeadCode.ll new file mode 100644 index 00000000000..743827df3f1 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2003-12-10-IndVarDeadCode.ll @@ -0,0 +1,23 @@ +; The induction variable canonicalization pass shouldn't leave dead +; instructions laying around! +; +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | not grep '#uses=0' + +int %mul(int %x, int %y) { +entry: + br label %tailrecurse + +tailrecurse: ; preds = %entry, %endif + %accumulator.tr = phi int [ %x, %entry ], [ %tmp.9, %endif ] ; <int> [#uses=2] + %y.tr = phi int [ %y, %entry ], [ %tmp.8, %endif ] ; <int> [#uses=2] + %tmp.1 = seteq int %y.tr, 0 ; <bool> [#uses=1] + br bool %tmp.1, label %return, label %endif + +endif: ; preds = %tailrecurse + %tmp.8 = add int %y.tr, -1 ; <int> [#uses=1] + %tmp.9 = add int %accumulator.tr, %x ; <int> [#uses=1] + br label %tailrecurse + +return: ; preds = %tailrecurse + ret int %accumulator.tr +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2003-12-10-RemoveInstrCrash.llx b/llvm/test/Transforms/IndVarsSimplify/2003-12-10-RemoveInstrCrash.llx new file mode 100644 index 00000000000..09d384ebb97 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2003-12-10-RemoveInstrCrash.llx @@ -0,0 +1,17 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + +void %test() { +entry: + %inc.2 = add int 1, 1 ; <int> [#uses=1] + br bool false, label %no_exit, label %loopexit + +no_exit: ; preds = %entry, %no_exit + %j.0.pn = phi int [ %inc.3, %no_exit ], [ %inc.2, %entry ] ; <int> [#uses=1] + %k.0.pn = phi int [ %inc.4, %no_exit ], [ 1, %entry ] ; <int> [#uses=1] + %inc.3 = add int %j.0.pn, 1 ; <int> [#uses=1] + %inc.4 = add int %k.0.pn, 1 ; <int> [#uses=1] + br bool false, label %no_exit, label %loopexit + +loopexit: ; preds = %entry, %no_exit + ret void +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2003-12-15-Crash.llx b/llvm/test/Transforms/IndVarsSimplify/2003-12-15-Crash.llx new file mode 100644 index 00000000000..372472811e1 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2003-12-15-Crash.llx @@ -0,0 +1,23 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output +void %_ZN17CoinFactorization7cleanupEv() { +entry: + br bool false, label %loopexit.14, label %cond_continue.3 + +cond_continue.3: ; preds = %entry + ret void + +loopexit.14: ; preds = %entry + %tmp.738 = sub int 0, 0 ; <int> [#uses=1] + br bool false, label %no_exit.15.preheader, label %loopexit.15 + +no_exit.15.preheader: ; preds = %loopexit.14 + br label %no_exit.15 + +no_exit.15: ; preds = %no_exit.15.preheader, %no_exit.15 + %highC.0 = phi int [ %tmp.738, %no_exit.15.preheader ], [ %dec.0, %no_exit.15 ] ; <int> [#uses=1] + %dec.0 = add int %highC.0, -1 ; <int> [#uses=1] + br bool false, label %no_exit.15, label %loopexit.15 + +loopexit.15: ; preds = %loopexit.14, %no_exit.15 + ret void +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2003-12-21-IndVarSize.ll b/llvm/test/Transforms/IndVarsSimplify/2003-12-21-IndVarSize.ll new file mode 100644 index 00000000000..26fecf45eeb --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2003-12-21-IndVarSize.ll @@ -0,0 +1,12 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep indvar | not grep uint + +%G = global long 0 + +void %test() { + br label %Loop +Loop: + %X = phi long [1, %0], [%X.next, %Loop] + %X.next = add long %X, 1 + store long %X, long* %G + br label %Loop +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2004-03-10-PHIInsertionBug.ll b/llvm/test/Transforms/IndVarsSimplify/2004-03-10-PHIInsertionBug.ll new file mode 100644 index 00000000000..88c393ea397 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2004-03-10-PHIInsertionBug.ll @@ -0,0 +1,27 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + +implementation ; Functions: + +void %test() { + br label %endif.0.i + +endif.0.i: ; preds = %then.0.i + br bool false, label %then.3.i, label %endif.3.i + +then.3.i: ; preds = %endif.0.i + br label %endif.3.i + +endif.3.i: ; preds = %endif.0.i, %then.3.i + %inxm.0.i = phi int [ 8, %then.3.i ], [ 0, %endif.0.i ] + %doinner.1.i = phi int [ 0, %then.3.i ], [ 0, %endif.0.i ] + br label %loopentry.2.i + +loopentry.2.i: ; preds = %endif.3.i, %no_exit.2.i + %inxk.0.i = phi int [ %tmp.210.i, %no_exit.2.i ], [ 0, %endif.3.i ] + br label %no_exit.2.i + +no_exit.2.i: ; preds = %loopentry.2.i + %tmp.210.i = sub int %inxk.0.i, %inxm.0.i + %tmp.213.i = add int %tmp.210.i, 0 + br label %loopentry.2.i +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2004-04-05-InvokeCastCrash.llx b/llvm/test/Transforms/IndVarsSimplify/2004-04-05-InvokeCastCrash.llx new file mode 100644 index 00000000000..c0d841024cc --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2004-04-05-InvokeCastCrash.llx @@ -0,0 +1,286 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + + %struct.__false_type = type { ubyte } + "struct.__gnu_cxx::_Hashtable_node<const llvm::Constant*>" = type { "struct.__gnu_cxx::_Hashtable_node<const llvm::Constant*>"*, "struct.llvm::Constant"* } + "struct.__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >" = type { "struct.__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >"*, "struct.std::pair<const llvm::Value* const,int>" } + "struct.__gnu_cxx::hash_map<const llvm::Value*,int,__gnu_cxx::hash<const llvm::Value*>,std::equal_to<const llvm::Value*>,std::allocator<int> >" = type { "struct.__gnu_cxx::hashtable<std::pair<const llvm::Value* const, int>,const llvm::Value*,__gnu_cxx::hash<const llvm::Value*>,std::_Select1st<std::pair<const llvm::Value* const, int> >,std::equal_to<const llvm::Value*>,std::allocator<int> >" } + "struct.__gnu_cxx::hash_set<const llvm::Constant*,__gnu_cxx::hash<const llvm::Constant*>,std::equal_to<const llvm::Constant*>,std::allocator<const llvm::Constant*> >" = type { "struct.__gnu_cxx::hashtable<const llvm::Constant*,const llvm::Constant*,__gnu_cxx::hash<const llvm::Constant*>,std::_Identity<const llvm::Constant*>,std::equal_to<const llvm::Constant*>,std::allocator<const llvm::Constant*> >" } + "struct.__gnu_cxx::hashtable<const llvm::Constant*,const llvm::Constant*,__gnu_cxx::hash<const llvm::Constant*>,std::_Identity<const llvm::Constant*>,std::equal_to<const llvm::Constant*>,std::allocator<const llvm::Constant*> >" = type { %struct.__false_type, %struct.__false_type, %struct.__false_type, %struct.__false_type, "struct.std::vector<__gnu_cxx::_Hashtable_node<const llvm::Constant*>*,std::allocator<const llvm::Constant*> >", uint } + "struct.__gnu_cxx::hashtable<std::pair<const llvm::Value* const, int>,const llvm::Value*,__gnu_cxx::hash<const llvm::Value*>,std::_Select1st<std::pair<const llvm::Value* const, int> >,std::equal_to<const llvm::Value*>,std::allocator<int> >" = type { %struct.__false_type, %struct.__false_type, %struct.__false_type, %struct.__false_type, "struct.std::vector<__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >*,std::allocator<int> >", uint } + "struct.llvm::AbstractTypeUser" = type { int (...)** } + "struct.llvm::Annotable" = type { int (...)**, "struct.llvm::Annotation"* } + "struct.llvm::Annotation" = type { int (...)**, "struct.llvm::AnnotationID", "struct.llvm::Annotation"* } + "struct.llvm::AnnotationID" = type { uint } + "struct.llvm::Argument" = type { "struct.llvm::Value", "struct.llvm::Function"*, "struct.llvm::Argument"*, "struct.llvm::Argument"* } + "struct.llvm::BasicBlock" = type { "struct.llvm::Value", "struct.llvm::iplist<llvm::Instruction,llvm::ilist_traits<llvm::Instruction> >", "struct.llvm::BasicBlock"*, "struct.llvm::BasicBlock"* } + "struct.llvm::Constant" = type opaque + "struct.llvm::DerivedType" = type { "struct.llvm::Type", "struct.llvm::AbstractTypeUser", "struct.std::vector<llvm::AbstractTypeUser*,std::allocator<llvm::AbstractTypeUser*> >" } + "struct.llvm::Function" = type { "struct.llvm::GlobalValue", "struct.llvm::Annotable", "struct.llvm::iplist<llvm::BasicBlock,llvm::ilist_traits<llvm::BasicBlock> >", "struct.llvm::iplist<llvm::Argument,llvm::ilist_traits<llvm::Argument> >", "struct.llvm::SymbolTable"*, "struct.llvm::Function"*, "struct.llvm::Function"* } + "struct.llvm::FunctionPass" = type { "struct.llvm::Pass" } + "struct.llvm::FunctionType" = type { "struct.llvm::DerivedType", bool } + "struct.llvm::GlobalValue" = type { "struct.llvm::User", uint, "struct.llvm::Module"* } + "struct.llvm::Instruction" = type { "struct.llvm::User", "struct.llvm::Annotable", "struct.llvm::BasicBlock"*, "struct.llvm::Instruction"*, "struct.llvm::Instruction"*, uint } + "struct.llvm::IntrinsicLowering" = type opaque + "struct.llvm::MachineBasicBlock" = type { "struct.llvm::ilist<llvm::MachineInstr>", "struct.llvm::MachineBasicBlock"*, "struct.llvm::MachineBasicBlock"*, "struct.llvm::BasicBlock"* } + "struct.llvm::MachineConstantPool" = type opaque + "struct.llvm::MachineFrameInfo" = type opaque + "struct.llvm::MachineFunction" = type { "struct.llvm::Annotation", "struct.llvm::Function"*, "struct.llvm::TargetMachine"*, "struct.llvm::iplist<llvm::MachineBasicBlock,llvm::ilist_traits<llvm::MachineBasicBlock> >", "struct.llvm::SSARegMap"*, "struct.llvm::MachineFunctionInfo"*, "struct.llvm::MachineFrameInfo"*, "struct.llvm::MachineConstantPool"* } + "struct.llvm::MachineFunctionInfo" = type { "struct.__gnu_cxx::hash_set<const llvm::Constant*,__gnu_cxx::hash<const llvm::Constant*>,std::equal_to<const llvm::Constant*>,std::allocator<const llvm::Constant*> >", "struct.__gnu_cxx::hash_map<const llvm::Value*,int,__gnu_cxx::hash<const llvm::Value*>,std::equal_to<const llvm::Value*>,std::allocator<int> >", uint, uint, uint, uint, uint, uint, uint, bool, bool, bool, "struct.llvm::MachineFunction"* } + "struct.llvm::MachineFunctionPass" = type { "struct.llvm::FunctionPass" } + "struct.llvm::MachineInstr" = type { short, ubyte, "struct.std::vector<llvm::MachineOperand,std::allocator<llvm::MachineOperand> >", "struct.llvm::MachineInstr"*, "struct.llvm::MachineInstr"*, "struct.llvm::MachineBasicBlock"* } + "struct.llvm::MachineInstrBuilder" = type { "struct.llvm::MachineInstr"* } + "struct.llvm::MachineOperand" = type { "union.llvm::MachineOperand::._65", int, int } + "struct.llvm::Module" = type opaque + "struct.llvm::PATypeHandle" = type { "struct.llvm::Type"*, "struct.llvm::AbstractTypeUser"* } + "struct.llvm::PATypeHolder" = type { "struct.llvm::Type"* } + "struct.llvm::Pass" = type { int (...)**, "struct.llvm::AbstractTypeUser"*, "struct.llvm::PassInfo"*, "struct.std::vector<std::pair<const llvm::PassInfo*, llvm::Pass*>,std::allocator<std::pair<const llvm::PassInfo*, llvm::Pass*> > >" } + "struct.llvm::PassInfo" = type { sbyte*, sbyte*, "struct.std::type_info"*, ubyte, "struct.std::vector<const llvm::PassInfo*,std::allocator<const llvm::PassInfo*> >", "struct.llvm::Pass"* ()*, "struct.llvm::Pass"* ("struct.llvm::TargetMachine"*)* } + "struct.llvm::SSARegMap" = type opaque + "struct.llvm::SymbolTable" = type opaque + "struct.llvm::SymbolTableListTraits<llvm::Argument,llvm::Function,llvm::Function,llvm::ilist_traits<llvm::Argument> >" = type { "struct.llvm::Function"*, "struct.llvm::Function"* } + "struct.llvm::SymbolTableListTraits<llvm::Instruction,llvm::BasicBlock,llvm::Function,llvm::ilist_traits<llvm::Instruction> >" = type { "struct.llvm::Function"*, "struct.llvm::BasicBlock"* } + "struct.llvm::TargetData" = type { "struct.llvm::FunctionPass", bool, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte, ubyte } + "struct.llvm::TargetFrameInfo" = type { int (...)**, uint, uint, int } + "struct.llvm::TargetInstrDescriptor" = type { sbyte*, int, int, uint, bool, uint, uint, uint, uint, uint, uint*, uint* } + "struct.llvm::TargetInstrInfo" = type { int (...)**, "struct.llvm::TargetInstrDescriptor"*, uint, uint } + "struct.llvm::TargetMachine" = type { int (...)**, "struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >", "struct.llvm::TargetData", "struct.llvm::IntrinsicLowering"* } + "struct.llvm::TargetRegClassInfo" = type { int (...)**, uint, uint, uint } + "struct.llvm::TargetRegInfo" = type { int (...)**, "struct.std::vector<const llvm::TargetRegClassInfo*,std::allocator<const llvm::TargetRegClassInfo*> >", "struct.llvm::TargetMachine"* } + "struct.llvm::Type" = type { "struct.llvm::Value", uint, uint, bool, uint, "struct.llvm::Type"*, "struct.std::vector<llvm::PATypeHandle,std::allocator<llvm::PATypeHandle> >" } + "struct.llvm::Use" = type { "struct.llvm::Value"*, "struct.llvm::User"*, "struct.llvm::Use"*, "struct.llvm::Use"* } + "struct.llvm::User" = type { "struct.llvm::Value", "struct.std::vector<llvm::Use,std::allocator<llvm::Use> >" } + "struct.llvm::Value" = type { int (...)**, "struct.llvm::iplist<llvm::Use,llvm::ilist_traits<llvm::Use> >", "struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >", "struct.llvm::PATypeHolder", uint } + "struct.llvm::_GLOBAL__N_::InsertPrologEpilogCode" = type { "struct.llvm::MachineFunctionPass" } + "struct.llvm::ilist<llvm::MachineInstr>" = type { "struct.llvm::iplist<llvm::MachineInstr,llvm::ilist_traits<llvm::MachineInstr> >" } + "struct.llvm::ilist_iterator<const llvm::MachineBasicBlock>" = type { "struct.llvm::MachineBasicBlock"* } + "struct.llvm::ilist_traits<llvm::Argument>" = type { "struct.llvm::SymbolTableListTraits<llvm::Argument,llvm::Function,llvm::Function,llvm::ilist_traits<llvm::Argument> >" } + "struct.llvm::ilist_traits<llvm::Instruction>" = type { "struct.llvm::SymbolTableListTraits<llvm::Instruction,llvm::BasicBlock,llvm::Function,llvm::ilist_traits<llvm::Instruction> >" } + "struct.llvm::iplist<llvm::Argument,llvm::ilist_traits<llvm::Argument> >" = type { "struct.llvm::ilist_traits<llvm::Argument>", "struct.llvm::Argument"*, "struct.llvm::Argument"* } + "struct.llvm::iplist<llvm::BasicBlock,llvm::ilist_traits<llvm::BasicBlock> >" = type { "struct.llvm::ilist_traits<llvm::Argument>", "struct.llvm::BasicBlock"*, "struct.llvm::BasicBlock"* } + "struct.llvm::iplist<llvm::Instruction,llvm::ilist_traits<llvm::Instruction> >" = type { "struct.llvm::ilist_traits<llvm::Instruction>", "struct.llvm::Instruction"*, "struct.llvm::Instruction"* } + "struct.llvm::iplist<llvm::MachineBasicBlock,llvm::ilist_traits<llvm::MachineBasicBlock> >" = type { "struct.llvm::MachineBasicBlock"*, "struct.llvm::MachineBasicBlock"* } + "struct.llvm::iplist<llvm::MachineInstr,llvm::ilist_traits<llvm::MachineInstr> >" = type { "struct.llvm::ilist_iterator<const llvm::MachineBasicBlock>", "struct.llvm::MachineInstr"*, "struct.llvm::MachineInstr"* } + "struct.llvm::iplist<llvm::Use,llvm::ilist_traits<llvm::Use> >" = type { "struct.llvm::Use"*, "struct.llvm::Use"* } + "struct.std::_Vector_alloc_base<__gnu_cxx::_Hashtable_node<const llvm::Constant*>*,std::allocator<const llvm::Constant*>, true>" = type { "struct.__gnu_cxx::_Hashtable_node<const llvm::Constant*>"**, "struct.__gnu_cxx::_Hashtable_node<const llvm::Constant*>"**, "struct.__gnu_cxx::_Hashtable_node<const llvm::Constant*>"** } + "struct.std::_Vector_alloc_base<__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >*,std::allocator<int>, true>" = type { "struct.__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >"**, "struct.__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >"**, "struct.__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >"** } + "struct.std::_Vector_alloc_base<const llvm::PassInfo*,std::allocator<const llvm::PassInfo*>, true>" = type { "struct.llvm::PassInfo"**, "struct.llvm::PassInfo"**, "struct.llvm::PassInfo"** } + "struct.std::_Vector_alloc_base<const llvm::TargetRegClassInfo*,std::allocator<const llvm::TargetRegClassInfo*>, true>" = type { "struct.llvm::TargetRegClassInfo"**, "struct.llvm::TargetRegClassInfo"**, "struct.llvm::TargetRegClassInfo"** } + "struct.std::_Vector_alloc_base<llvm::AbstractTypeUser*,std::allocator<llvm::AbstractTypeUser*>, true>" = type { "struct.llvm::AbstractTypeUser"**, "struct.llvm::AbstractTypeUser"**, "struct.llvm::AbstractTypeUser"** } + "struct.std::_Vector_alloc_base<llvm::MachineInstr*,std::allocator<llvm::MachineInstr*>, true>" = type { "struct.llvm::MachineInstr"**, "struct.llvm::MachineInstr"**, "struct.llvm::MachineInstr"** } + "struct.std::_Vector_alloc_base<llvm::MachineOperand,std::allocator<llvm::MachineOperand>, true>" = type { "struct.llvm::MachineOperand"*, "struct.llvm::MachineOperand"*, "struct.llvm::MachineOperand"* } + "struct.std::_Vector_alloc_base<llvm::PATypeHandle,std::allocator<llvm::PATypeHandle>, true>" = type { "struct.llvm::PATypeHandle"*, "struct.llvm::PATypeHandle"*, "struct.llvm::PATypeHandle"* } + "struct.std::_Vector_alloc_base<llvm::Use,std::allocator<llvm::Use>, true>" = type { "struct.llvm::Use"*, "struct.llvm::Use"*, "struct.llvm::Use"* } + "struct.std::_Vector_alloc_base<std::pair<const llvm::PassInfo*, llvm::Pass*>,std::allocator<std::pair<const llvm::PassInfo*, llvm::Pass*> >, true>" = type { "struct.std::pair<const llvm::PassInfo*,llvm::Pass*>"*, "struct.std::pair<const llvm::PassInfo*,llvm::Pass*>"*, "struct.std::pair<const llvm::PassInfo*,llvm::Pass*>"* } + "struct.std::_Vector_base<__gnu_cxx::_Hashtable_node<const llvm::Constant*>*,std::allocator<const llvm::Constant*> >" = type { "struct.std::_Vector_alloc_base<__gnu_cxx::_Hashtable_node<const llvm::Constant*>*,std::allocator<const llvm::Constant*>, true>" } + "struct.std::_Vector_base<__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >*,std::allocator<int> >" = type { "struct.std::_Vector_alloc_base<__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >*,std::allocator<int>, true>" } + "struct.std::_Vector_base<const llvm::PassInfo*,std::allocator<const llvm::PassInfo*> >" = type { "struct.std::_Vector_alloc_base<const llvm::PassInfo*,std::allocator<const llvm::PassInfo*>, true>" } + "struct.std::_Vector_base<const llvm::TargetRegClassInfo*,std::allocator<const llvm::TargetRegClassInfo*> >" = type { "struct.std::_Vector_alloc_base<const llvm::TargetRegClassInfo*,std::allocator<const llvm::TargetRegClassInfo*>, true>" } + "struct.std::_Vector_base<llvm::AbstractTypeUser*,std::allocator<llvm::AbstractTypeUser*> >" = type { "struct.std::_Vector_alloc_base<llvm::AbstractTypeUser*,std::allocator<llvm::AbstractTypeUser*>, true>" } + "struct.std::_Vector_base<llvm::MachineInstr*,std::allocator<llvm::MachineInstr*> >" = type { "struct.std::_Vector_alloc_base<llvm::MachineInstr*,std::allocator<llvm::MachineInstr*>, true>" } + "struct.std::_Vector_base<llvm::MachineOperand,std::allocator<llvm::MachineOperand> >" = type { "struct.std::_Vector_alloc_base<llvm::MachineOperand,std::allocator<llvm::MachineOperand>, true>" } + "struct.std::_Vector_base<llvm::PATypeHandle,std::allocator<llvm::PATypeHandle> >" = type { "struct.std::_Vector_alloc_base<llvm::PATypeHandle,std::allocator<llvm::PATypeHandle>, true>" } + "struct.std::_Vector_base<llvm::Use,std::allocator<llvm::Use> >" = type { "struct.std::_Vector_alloc_base<llvm::Use,std::allocator<llvm::Use>, true>" } + "struct.std::_Vector_base<std::pair<const llvm::PassInfo*, llvm::Pass*>,std::allocator<std::pair<const llvm::PassInfo*, llvm::Pass*> > >" = type { "struct.std::_Vector_alloc_base<std::pair<const llvm::PassInfo*, llvm::Pass*>,std::allocator<std::pair<const llvm::PassInfo*, llvm::Pass*> >, true>" } + "struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >" = type { "struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Alloc_hider" } + "struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Alloc_hider" = type { sbyte* } + "struct.std::pair<const llvm::PassInfo*,llvm::Pass*>" = type { "struct.llvm::PassInfo"*, "struct.llvm::Pass"* } + "struct.std::pair<const llvm::Value* const,int>" = type { "struct.llvm::Value"*, int } + "struct.std::type_info" = type { int (...)**, sbyte* } + "struct.std::vector<__gnu_cxx::_Hashtable_node<const llvm::Constant*>*,std::allocator<const llvm::Constant*> >" = type { "struct.std::_Vector_base<__gnu_cxx::_Hashtable_node<const llvm::Constant*>*,std::allocator<const llvm::Constant*> >" } + "struct.std::vector<__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >*,std::allocator<int> >" = type { "struct.std::_Vector_base<__gnu_cxx::_Hashtable_node<std::pair<const llvm::Value* const, int> >*,std::allocator<int> >" } + "struct.std::vector<const llvm::PassInfo*,std::allocator<const llvm::PassInfo*> >" = type { "struct.std::_Vector_base<const llvm::PassInfo*,std::allocator<const llvm::PassInfo*> >" } + "struct.std::vector<const llvm::TargetRegClassInfo*,std::allocator<const llvm::TargetRegClassInfo*> >" = type { "struct.std::_Vector_base<const llvm::TargetRegClassInfo*,std::allocator<const llvm::TargetRegClassInfo*> >" } + "struct.std::vector<llvm::AbstractTypeUser*,std::allocator<llvm::AbstractTypeUser*> >" = type { "struct.std::_Vector_base<llvm::AbstractTypeUser*,std::allocator<llvm::AbstractTypeUser*> >" } + "struct.std::vector<llvm::MachineInstr*,std::allocator<llvm::MachineInstr*> >" = type { "struct.std::_Vector_base<llvm::MachineInstr*,std::allocator<llvm::MachineInstr*> >" } + "struct.std::vector<llvm::MachineOperand,std::allocator<llvm::MachineOperand> >" = type { "struct.std::_Vector_base<llvm::MachineOperand,std::allocator<llvm::MachineOperand> >" } + "struct.std::vector<llvm::PATypeHandle,std::allocator<llvm::PATypeHandle> >" = type { "struct.std::_Vector_base<llvm::PATypeHandle,std::allocator<llvm::PATypeHandle> >" } + "struct.std::vector<llvm::Use,std::allocator<llvm::Use> >" = type { "struct.std::_Vector_base<llvm::Use,std::allocator<llvm::Use> >" } + "struct.std::vector<std::pair<const llvm::PassInfo*, llvm::Pass*>,std::allocator<std::pair<const llvm::PassInfo*, llvm::Pass*> > >" = type { "struct.std::_Vector_base<std::pair<const llvm::PassInfo*, llvm::Pass*>,std::allocator<std::pair<const llvm::PassInfo*, llvm::Pass*> > >" } + "union.llvm::MachineOperand::._65" = type { "struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >"* } + +implementation ; Functions: + +declare void %_Znwj() + +declare void %_ZN4llvm12MachineInstrC1Esjbb() + +declare void %_ZNSt6vectorIPN4llvm12MachineInstrESaIS2_EE9push_backERKS2_() + +declare void %_ZNK4llvm8Function15getFunctionTypeEv() + +declare void %_ZNK4llvm19MachineInstrBuilder7addMRegEiNS_14MachineOperand7UseTypeE() + +declare void %_ZNK4llvm19MachineInstrBuilder7addSImmEi() + +void %_ZN4llvm11_GLOBAL__N_22InsertPrologEpilogCode20runOnMachineFunctionERNS_15MachineFunctionE("struct.llvm::MachineFunction"* %F) { +entry: + %tmp.8.i = invoke "struct.llvm::TargetFrameInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %invoke_cont.0.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetFrameInfo"*> [#uses=0] + +invoke_catch.0.i: ; preds = %entry, %invoke_cont.0.i, %tmp.7.i.noexc.i, %endif.0.i.i, %invoke_cont.1.i, %invoke_cont.2.i, %invoke_cont.3.i, %invoke_cont.4.i, %then.0.i, %invoke_cont.i.i, %invoke_cont.7.i, %invoke_cont.8.i, %invoke_cont.9.i, %endif.0.i, %then.1.i, %invoke_cont.34.i, %invoke_cont.35.i, %then.2.i, %invoke_cont.37.i, %invoke_cont.38.i, %invoke_cont.39.i, %invoke_cont.40.i, %invoke_cont.41.i, %invoke_cont.42.i, %invoke_cont.43.i, %invoke_cont.44.i, %no_exit.i, %invoke_cont.i53.i, %invoke_cont.47.i, %invoke_cont.48.i, %invoke_cont.49.i + ret void + +invoke_cont.0.i: ; preds = %entry + %tmp.7.i1.i = invoke "struct.llvm::TargetFrameInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %tmp.7.i.noexc.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetFrameInfo"*> [#uses=2] + +tmp.7.i.noexc.i: ; preds = %invoke_cont.0.i + %tmp.17.i2.i = invoke int null( "struct.llvm::TargetFrameInfo"* %tmp.7.i1.i ) + to label %endif.0.i.i unwind label %invoke_catch.0.i ; <int> [#uses=0] + +endif.0.i.i: ; preds = %tmp.7.i.noexc.i + %tmp.38.i4.i = invoke int null( "struct.llvm::TargetFrameInfo"* %tmp.7.i1.i ) + to label %tmp.38.i.noexc.i unwind label %invoke_catch.0.i ; <int> [#uses=0] + +tmp.38.i.noexc.i: ; preds = %endif.0.i.i + br bool false, label %invoke_cont.1.i, label %then.1.i.i + +then.1.i.i: ; preds = %tmp.38.i.noexc.i + ret void + +invoke_cont.1.i: ; preds = %tmp.38.i.noexc.i + %tmp.21.i = invoke "struct.llvm::TargetRegInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %invoke_cont.2.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetRegInfo"*> [#uses=1] + +invoke_cont.2.i: ; preds = %invoke_cont.1.i + %tmp.28.i = invoke uint null( "struct.llvm::TargetRegInfo"* %tmp.21.i ) + to label %invoke_cont.3.i unwind label %invoke_catch.0.i ; <uint> [#uses=0] + +invoke_cont.3.i: ; preds = %invoke_cont.2.i + %tmp.36.i = invoke "struct.llvm::TargetInstrInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %invoke_cont.4.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetInstrInfo"*> [#uses=1] + +invoke_cont.4.i: ; preds = %invoke_cont.3.i + %tmp.43.i = invoke bool null( "struct.llvm::TargetInstrInfo"* %tmp.36.i, short 383, long 0 ) + to label %invoke_cont.5.i unwind label %invoke_catch.0.i ; <bool> [#uses=1] + +invoke_cont.5.i: ; preds = %invoke_cont.4.i + br bool %tmp.43.i, label %then.0.i, label %else.i + +then.0.i: ; preds = %invoke_cont.5.i + invoke void %_Znwj( ) + to label %tmp.0.i.noexc.i unwind label %invoke_catch.0.i + +tmp.0.i.noexc.i: ; preds = %then.0.i + invoke void %_ZN4llvm12MachineInstrC1Esjbb( ) + to label %invoke_cont.i.i unwind label %cond_true.i.i + +cond_true.i.i: ; preds = %tmp.0.i.noexc.i + ret void + +invoke_cont.i.i: ; preds = %tmp.0.i.noexc.i + invoke void %_ZNK4llvm19MachineInstrBuilder7addMRegEiNS_14MachineOperand7UseTypeE( ) + to label %invoke_cont.7.i unwind label %invoke_catch.0.i + +invoke_cont.7.i: ; preds = %invoke_cont.i.i + invoke void %_ZNK4llvm19MachineInstrBuilder7addSImmEi( ) + to label %invoke_cont.8.i unwind label %invoke_catch.0.i + +invoke_cont.8.i: ; preds = %invoke_cont.7.i + invoke void %_ZNK4llvm19MachineInstrBuilder7addMRegEiNS_14MachineOperand7UseTypeE( ) + to label %invoke_cont.9.i unwind label %invoke_catch.0.i + +invoke_cont.9.i: ; preds = %invoke_cont.8.i + invoke void %_ZNSt6vectorIPN4llvm12MachineInstrESaIS2_EE9push_backERKS2_( ) + to label %endif.0.i unwind label %invoke_catch.0.i + +else.i: ; preds = %invoke_cont.5.i + ret void + +endif.0.i: ; preds = %invoke_cont.9.i + invoke void %_ZNK4llvm8Function15getFunctionTypeEv( ) + to label %invoke_cont.33.i unwind label %invoke_catch.0.i + +invoke_cont.33.i: ; preds = %endif.0.i + br bool false, label %then.1.i, label %endif.1.i + +then.1.i: ; preds = %invoke_cont.33.i + invoke void %_ZNK4llvm8Function15getFunctionTypeEv( ) + to label %invoke_cont.34.i unwind label %invoke_catch.0.i + +invoke_cont.34.i: ; preds = %then.1.i + %tmp.121.i = invoke "struct.llvm::TargetRegInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %invoke_cont.35.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetRegInfo"*> [#uses=1] + +invoke_cont.35.i: ; preds = %invoke_cont.34.i + %tmp.128.i = invoke uint null( "struct.llvm::TargetRegInfo"* %tmp.121.i ) + to label %invoke_cont.36.i unwind label %invoke_catch.0.i ; <uint> [#uses=0] + +invoke_cont.36.i: ; preds = %invoke_cont.35.i + br bool false, label %then.2.i, label %endif.1.i + +then.2.i: ; preds = %invoke_cont.36.i + %tmp.140.i = invoke "struct.llvm::TargetRegInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %invoke_cont.37.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetRegInfo"*> [#uses=0] + +invoke_cont.37.i: ; preds = %then.2.i + %tmp.148.i = invoke "struct.llvm::TargetRegInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %invoke_cont.38.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetRegInfo"*> [#uses=1] + +invoke_cont.38.i: ; preds = %invoke_cont.37.i + %tmp.155.i = invoke uint null( "struct.llvm::TargetRegInfo"* %tmp.148.i, "struct.llvm::Type"* null, bool false ) + to label %invoke_cont.39.i unwind label %invoke_catch.0.i ; <uint> [#uses=0] + +invoke_cont.39.i: ; preds = %invoke_cont.38.i + %tmp.163.i = invoke "struct.llvm::TargetFrameInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %invoke_cont.40.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetFrameInfo"*> [#uses=1] + +invoke_cont.40.i: ; preds = %invoke_cont.39.i + %tmp.170.i = invoke int null( "struct.llvm::TargetFrameInfo"* %tmp.163.i ) + to label %invoke_cont.41.i unwind label %invoke_catch.0.i ; <int> [#uses=0] + +invoke_cont.41.i: ; preds = %invoke_cont.40.i + %tmp.177.i = invoke "struct.llvm::TargetFrameInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %invoke_cont.42.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetFrameInfo"*> [#uses=1] + +invoke_cont.42.i: ; preds = %invoke_cont.41.i + %tmp.184.i = invoke int null( "struct.llvm::TargetFrameInfo"* %tmp.177.i ) + to label %invoke_cont.43.i unwind label %invoke_catch.0.i ; <int> [#uses=1] + +invoke_cont.43.i: ; preds = %invoke_cont.42.i + %tmp.191.i = invoke "struct.llvm::TargetFrameInfo"* null( "struct.llvm::TargetMachine"* null ) + to label %invoke_cont.44.i unwind label %invoke_catch.0.i ; <"struct.llvm::TargetFrameInfo"*> [#uses=1] + +invoke_cont.44.i: ; preds = %invoke_cont.43.i + %tmp.198.i = invoke int null( "struct.llvm::TargetFrameInfo"* %tmp.191.i, "struct.llvm::MachineFunction"* %F, bool* null ) + to label %invoke_cont.45.i unwind label %invoke_catch.0.i ; <int> [#uses=0] + +invoke_cont.45.i: ; preds = %invoke_cont.44.i + br bool false, label %no_exit.i, label %endif.1.i + +no_exit.i: ; preds = %invoke_cont.45.i, %invoke_cont.50.i + %nextArgOffset.0.i.1 = phi int [ %tmp.221.i, %invoke_cont.50.i ], [ 0, %invoke_cont.45.i ] ; <int> [#uses=1] + invoke void %_Znwj( ) + to label %tmp.0.i.noexc55.i unwind label %invoke_catch.0.i + +tmp.0.i.noexc55.i: ; preds = %no_exit.i + invoke void %_ZN4llvm12MachineInstrC1Esjbb( ) + to label %invoke_cont.i53.i unwind label %cond_true.i52.i + +cond_true.i52.i: ; preds = %tmp.0.i.noexc55.i + ret void + +invoke_cont.i53.i: ; preds = %tmp.0.i.noexc55.i + invoke void %_ZNK4llvm19MachineInstrBuilder7addMRegEiNS_14MachineOperand7UseTypeE( ) + to label %invoke_cont.47.i unwind label %invoke_catch.0.i + +invoke_cont.47.i: ; preds = %invoke_cont.i53.i + invoke void %_ZNK4llvm19MachineInstrBuilder7addMRegEiNS_14MachineOperand7UseTypeE( ) + to label %invoke_cont.48.i unwind label %invoke_catch.0.i + +invoke_cont.48.i: ; preds = %invoke_cont.47.i + invoke void %_ZNK4llvm19MachineInstrBuilder7addSImmEi( ) + to label %invoke_cont.49.i unwind label %invoke_catch.0.i + +invoke_cont.49.i: ; preds = %invoke_cont.48.i + invoke void %_ZNSt6vectorIPN4llvm12MachineInstrESaIS2_EE9push_backERKS2_( ) + to label %invoke_cont.50.i unwind label %invoke_catch.0.i + +invoke_cont.50.i: ; preds = %invoke_cont.49.i + %tmp.221.i = add int %nextArgOffset.0.i.1, %tmp.184.i ; <int> [#uses=1] + br bool false, label %no_exit.i, label %endif.1.i + +endif.1.i: ; preds = %invoke_cont.33.i, %invoke_cont.36.i, %invoke_cont.45.i, %invoke_cont.50.i + ret void +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/2004-04-07-ScalarEvolutionCrash.llx b/llvm/test/Transforms/IndVarsSimplify/2004-04-07-ScalarEvolutionCrash.llx new file mode 100644 index 00000000000..82212d5c720 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2004-04-07-ScalarEvolutionCrash.llx @@ -0,0 +1,26 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + +void %.outPlank_21() { +entry: + br bool false, label %loopexit.0, label %no_exit.0 + +no_exit.0: ; preds = %entry + ret void + +loopexit.0: ; preds = %entry + br bool false, label %no_exit.1, label %loopexit.1 + +no_exit.1: ; preds = %loopexit.0, %loopexit.2 + %i.0.0 = phi int [ %inc, %loopexit.2 ], [ 0, %loopexit.0 ] ; <int> [#uses=1] + br bool false, label %loopexit.2, label %no_exit.2 + +no_exit.2: ; preds = %no_exit.1 + ret void + +loopexit.2: ; preds = %no_exit.1 + %inc = add int %i.0.0, 1 ; <int> [#uses=1] + br bool false, label %no_exit.1, label %loopexit.1 + +loopexit.1: ; preds = %loopexit.0, %loopexit.2 + ret void +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll b/llvm/test/Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll new file mode 100644 index 00000000000..92a48308b2a --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2005-02-11-InvokeCrash.ll @@ -0,0 +1,22 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + +void %_ZN5ArrayISt7complexIdEEC2ERK10dim_vector() { +entry: + %tmp.7 = invoke int %_ZN5ArrayISt7complexIdEE8get_sizeERK10dim_vector( ) + to label %invoke_cont.0 unwind label %cond_true.1 ; <int> [#uses=2] + +cond_true.1: ; preds = %entry + unwind + +invoke_cont.0: ; preds = %entry + %tmp.4.i = cast int %tmp.7 to uint ; <uint> [#uses=0] + %tmp.14.0.i5 = add int %tmp.7, -1 ; <int> [#uses=1] + br label %no_exit.i + +no_exit.i: ; preds = %no_exit.i, %invoke_cont.0 + %tmp.14.0.i.0 = phi int [ %tmp.14.0.i, %no_exit.i ], [ %tmp.14.0.i5, %invoke_cont.0 ] ; <int> [#uses=1] + %tmp.14.0.i = add int %tmp.14.0.i.0, -1 ; <int> [#uses=1] + br label %no_exit.i +} + +declare int %_ZN5ArrayISt7complexIdEE8get_sizeERK10dim_vector() diff --git a/llvm/test/Transforms/IndVarsSimplify/2005-02-17-TruncateExprCrash.ll b/llvm/test/Transforms/IndVarsSimplify/2005-02-17-TruncateExprCrash.ll new file mode 100644 index 00000000000..5ba8bdb622f --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2005-02-17-TruncateExprCrash.ll @@ -0,0 +1,63 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + +implementation ; Functions: + +declare void %q_atomic_increment() + +declare void %_Z9qt_assertPKcS0_i() + +void %_ZN13QMetaResourceC1EPKh() { +entry: + invoke void %_Z9qt_assertPKcS0_i( ) + to label %endif.1 unwind label %then.i.i551 + +then.i.i551: ; preds = %entry + ret void + +endif.1: ; preds = %entry + br bool false, label %then.2, label %then.i.i + +then.2: ; preds = %endif.1 + invoke void %q_atomic_increment( ) + to label %loopentry.0 unwind label %invoke_catch.6 + +invoke_catch.6: ; preds = %then.2 + ret void + +loopentry.0: ; preds = %then.2 + br bool false, label %shortcirc_next.i, label %endif.3 + +endif.3: ; preds = %loopentry.0 + ret void + +shortcirc_next.i: ; preds = %loopentry.0 + br bool false, label %_ZNK7QString2atEi.exit, label %then.i + +then.i: ; preds = %shortcirc_next.i + ret void + +_ZNK7QString2atEi.exit: ; preds = %shortcirc_next.i + br bool false, label %endif.4, label %then.4 + +then.4: ; preds = %_ZNK7QString2atEi.exit + ret void + +endif.4: ; preds = %_ZNK7QString2atEi.exit + %tmp.115 = load ubyte* null ; <ubyte> [#uses=1] + br bool false, label %loopexit.1, label %no_exit.0 + +no_exit.0: ; preds = %no_exit.0, %endif.4 + %bytes_in_len.4.5 = phi ubyte [ %dec, %no_exit.0 ], [ %tmp.115, %endif.4 ] ; <ubyte> [#uses=1] + %off.5.5.in = phi int [ %off.5.5, %no_exit.0 ], [ 0, %endif.4 ] ; <int> [#uses=1] + %off.5.5 = add int %off.5.5.in, 1 ; <int> [#uses=2] + %dec = add ubyte %bytes_in_len.4.5, 255 ; <ubyte> [#uses=2] + %tmp.123631 = seteq ubyte %dec, 0 ; <bool> [#uses=1] + br bool %tmp.123631, label %loopexit.1, label %no_exit.0 + +loopexit.1: ; preds = %no_exit.0, %endif.4 + %off.5.in.6 = phi int [ 0, %endif.4 ], [ %off.5.5, %no_exit.0 ] ; <int> [#uses=0] + ret void + +then.i.i: ; preds = %endif.1 + ret void +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2005-02-26-ExitValueCompute.ll b/llvm/test/Transforms/IndVarsSimplify/2005-02-26-ExitValueCompute.ll new file mode 100644 index 00000000000..8fcd8e44c85 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2005-02-26-ExitValueCompute.ll @@ -0,0 +1,19 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep 'ret i32 152' + +int %main() { +entry: + br label %no_exit + +no_exit: ; preds = %no_exit, %entry + %i.1.0 = phi int [ 0, %entry ], [ %inc, %no_exit ] ; <int> [#uses=2] + %tmp.4 = setgt int %i.1.0, 50 ; <bool> [#uses=1] + %tmp.7 = select bool %tmp.4, int 100, int 0 ; <int> [#uses=1] + %i.0 = add int %i.1.0, 1 ; <int> [#uses=1] + %inc = add int %i.0, %tmp.7 ; <int> [#uses=3] + %tmp.1 = setlt int %inc, 100 ; <bool> [#uses=1] + br bool %tmp.1, label %no_exit, label %loopexit + +loopexit: ; preds = %no_exit + ret int %inc +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/2005-06-15-InstMoveCrash.ll b/llvm/test/Transforms/IndVarsSimplify/2005-06-15-InstMoveCrash.ll new file mode 100644 index 00000000000..896482c29b2 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2005-06-15-InstMoveCrash.ll @@ -0,0 +1,36 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + +void %main() { +entry: + br label %no_exit.1.outer + +no_exit.1.outer: ; preds = %endif.0, %entry + %l_14237116.1.0.ph = phi sbyte [ -46, %entry ], [ 0, %endif.0 ] ; <sbyte> [#uses=1] + %i.0.0.0.ph = phi int [ 0, %entry ], [ %inc.1, %endif.0 ] ; <int> [#uses=1] + br label %no_exit.1 + +no_exit.1: ; preds = %_Z13func_47880058cc.exit, %no_exit.1.outer + br bool false, label %_Z13func_47880058cc.exit, label %then.i + +then.i: ; preds = %no_exit.1 + br label %_Z13func_47880058cc.exit + +_Z13func_47880058cc.exit: ; preds = %then.i, %no_exit.1 + br bool false, label %then.0, label %no_exit.1 + +then.0: ; preds = %_Z13func_47880058cc.exit + %tmp.6 = cast sbyte %l_14237116.1.0.ph to ubyte ; <ubyte> [#uses=1] + br bool false, label %endif.0, label %then.1 + +then.1: ; preds = %then.0 + br label %endif.0 + +endif.0: ; preds = %then.1, %then.0 + %inc.1 = add int %i.0.0.0.ph, 1 ; <int> [#uses=2] + %tmp.2 = setgt int %inc.1, 99 ; <bool> [#uses=1] + br bool %tmp.2, label %loopexit.0, label %no_exit.1.outer + +loopexit.0: ; preds = %endif.0 + %tmp.28 = cast ubyte %tmp.6 to uint ; <uint> [#uses=0] + ret void +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2005-11-18-Crash.ll b/llvm/test/Transforms/IndVarsSimplify/2005-11-18-Crash.ll new file mode 100644 index 00000000000..9960e5cdb2b --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2005-11-18-Crash.ll @@ -0,0 +1,18 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + +%fixtab = external global [29 x [29 x [2 x uint]]] ; <[29 x [29 x [2 x uint]]]*> [#uses=1] + +implementation ; Functions: + +void %init_optabs() { +entry: + br label %no_exit.0 + +no_exit.0: ; preds = %no_exit.0, %entry + %p.0.0 = phi uint* [ getelementptr ([29 x [29 x [2 x uint]]]* %fixtab, int 0, int 0, int 0, int 0), %entry ], [ %inc.0, %no_exit.0 ] ; <uint*> [#uses=1] + %inc.0 = getelementptr uint* %p.0.0, int 1 ; <uint*> [#uses=1] + br bool false, label %no_exit.0, label %no_exit.1 + +no_exit.1: ; preds = %no_exit.0 + ret void +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2006-03-31-NegativeStride.ll b/llvm/test/Transforms/IndVarsSimplify/2006-03-31-NegativeStride.ll new file mode 100644 index 00000000000..deb9abd382b --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2006-03-31-NegativeStride.ll @@ -0,0 +1,21 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep 'ret i32 27' + +; Make sure to compute the right exit value based on negative strides. +; PR726 + +int %test() { +entry: + br label %cond_true + +cond_true: ; preds = %cond_true, %entry + %a.0.0 = phi int [ 10, %entry ], [ %tmp4, %cond_true ] ; <int> [#uses=2] + %b.0.0 = phi int [ 0, %entry ], [ %tmp2, %cond_true ] ; <int> [#uses=1] + %tmp2 = add int %b.0.0, %a.0.0 ; <int> [#uses=2] + %tmp4 = add int %a.0.0, -1 ; <int> [#uses=2] + %tmp = setgt int %tmp4, 7 ; <bool> [#uses=1] + br bool %tmp, label %cond_true, label %bb7 + +bb7: ; preds = %cond_true + ret int %tmp2 +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/2006-06-16-Indvar-LCSSA-Crash.ll b/llvm/test/Transforms/IndVarsSimplify/2006-06-16-Indvar-LCSSA-Crash.ll new file mode 100644 index 00000000000..1fe8026ef43 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2006-06-16-Indvar-LCSSA-Crash.ll @@ -0,0 +1,21 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + +void %get_block() { +endif.0: ; preds = %entry + br label %no_exit.30 + +no_exit.30: ; preds = %no_exit.30, %endif.0 + %x.12.0 = phi int [ %inc.28, %no_exit.30 ], [ -2, %endif.0 ] ; <int> [#uses=1] + %tmp.583 = load ushort* null ; <ushort> [#uses=1] + %tmp.584 = cast ushort %tmp.583 to int ; <int> [#uses=1] + %tmp.588 = load int* null ; <int> [#uses=1] + %tmp.589 = mul int %tmp.584, %tmp.588 ; <int> [#uses=1] + %tmp.591 = add int %tmp.589, 0 ; <int> [#uses=1] + %inc.28 = add int %x.12.0, 1 ; <int> [#uses=2] + %tmp.565 = setgt int %inc.28, 3 ; <bool> [#uses=1] + br bool %tmp.565, label %loopexit.30, label %no_exit.30 + +loopexit.30: ; preds = %no_exit.30 + %tmp.591.lcssa = phi int [ %tmp.591, %no_exit.30 ] ; <int> [#uses=0] + ret void +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2006-09-20-LFTR-Crash.ll b/llvm/test/Transforms/IndVarsSimplify/2006-09-20-LFTR-Crash.ll new file mode 100644 index 00000000000..88872f67c91 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2006-09-20-LFTR-Crash.ll @@ -0,0 +1,46 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + + %struct.p7prior_s = type { int, int, [200 x float], [200 x [7 x float]], int, [200 x float], [200 x [20 x float]], int, [200 x float], [200 x [20 x float]] } + +implementation ; Functions: + +void %P7DefaultPrior() { +entry: + switch int 0, label %UnifiedReturnBlock [ + int 2, label %bb160 + int 3, label %bb + ] + +bb: ; preds = %entry + br bool false, label %cond_true.i, label %sre_malloc.exit + +cond_true.i: ; preds = %bb + unreachable + +sre_malloc.exit: ; preds = %bb + br label %cond_true + +cond_true: ; preds = %cond_true66, %cond_true, %sre_malloc.exit + %tmp59 = phi int [ 1, %sre_malloc.exit ], [ %phitmp, %cond_true66 ], [ %tmp59, %cond_true ] ; <int> [#uses=2] + %indvar245.0.ph = phi uint [ 0, %sre_malloc.exit ], [ %indvar.next246, %cond_true66 ], [ %indvar245.0.ph, %cond_true ] ; <uint> [#uses=2] + br bool false, label %bb57, label %cond_true + +bb57: ; preds = %cond_true + %tmp65 = setgt int 0, %tmp59 ; <bool> [#uses=1] + %indvar.next246 = add uint %indvar245.0.ph, 1 ; <uint> [#uses=2] + br bool %tmp65, label %cond_true66, label %bb69 + +cond_true66: ; preds = %bb57 + %q.1.0 = cast uint %indvar.next246 to int ; <int> [#uses=1] + %phitmp = add int %q.1.0, 1 ; <int> [#uses=1] + br label %cond_true + +bb69: ; preds = %bb57 + ret void + +bb160: ; preds = %entry + ret void + +UnifiedReturnBlock: ; preds = %entry + ret void +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2006-12-10-BitCast.ll b/llvm/test/Transforms/IndVarsSimplify/2006-12-10-BitCast.ll new file mode 100644 index 00000000000..4d2a29b22bc --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2006-12-10-BitCast.ll @@ -0,0 +1,38 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -disable-output + +target datalayout = "e-p:32:32" +target endian = little +target pointersize = 32 +target triple = "i686-apple-darwin8" + %struct.vorbis_dsp_state = type { int, %struct.vorbis_info*, float**, float**, int, int, int, int, int, int, int, int, int, long, long, long, long, long, long, sbyte* } + %struct.vorbis_info = type { int, int, int, int, int, int, int, sbyte* } + +implementation ; Functions: + +void %_ve_envelope_search() { +entry: + br bool false, label %cond_true27, label %bb137 + +cond_true27: ; preds = %entry + br bool false, label %cond_true52, label %bb80 + +cond_true52: ; preds = %cond_true27 + %tmp152.i = bitcast float 0.000000e+00 to uint ; <uint> [#uses=1] + br label %cond_next182.i + +cond_next182.i: ; preds = %cond_next182.i, %cond_true52 + %decay.i.0 = phi uint [ %tmp195.i, %cond_next182.i ], [ %tmp152.i, %cond_true52 ] ; <uint> [#uses=1] + %tmp194.i53 = bitcast uint %decay.i.0 to float ; <float> [#uses=1] + %tmp195.i = sub float %tmp194.i53, 8.000000e+00 ; <float> [#uses=1] + %tmp195.i = bitcast float %tmp195.i to uint ; <uint> [#uses=1] + br bool false, label %cond_next182.i, label %bb418.i.preheader + +bb418.i.preheader: ; preds = %cond_next182.i + ret void + +bb80: ; preds = %cond_true27 + ret void + +bb137: ; preds = %entry + ret void +} diff --git a/llvm/test/Transforms/IndVarsSimplify/2007-01-06-TripCount.ll b/llvm/test/Transforms/IndVarsSimplify/2007-01-06-TripCount.ll new file mode 100644 index 00000000000..72757227830 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2007-01-06-TripCount.ll @@ -0,0 +1,42 @@ +; RUN: llvm-as < %s | opt -indvars -disable-output && +; RUN: llvm-as < %s | opt -indvars | llvm-dis | not grep 'ret i32 0' +; PR1015 + +target datalayout = "e-p:32:32" +target endian = little +target pointersize = 32 +target triple = "i686-apple-darwin8" +%foo = internal constant [5 x i8] c"\00abc\00" ; <[5 x i8]*> [#uses=1] +%str = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1] + +implementation ; Functions: + +define i32 %test(i32 %J) { +entry: + br label %bb2 + +bb: ; preds = %cond_next, %cond_true + %tmp1 = add i32 %i.0, 1 ; <i32> [#uses=1] + br label %bb2 + +bb2: ; preds = %bb, %entry + %i.0 = phi i32 [ 0, %entry ], [ %tmp1, %bb ] ; <i32> [#uses=4] + %tmp = icmp eq i32 %i.0, 0 ; <i1> [#uses=1] + br i1 %tmp, label %cond_true, label %cond_next + +cond_true: ; preds = %bb2 + br label %bb + +cond_next: ; preds = %bb2 + %tmp = getelementptr [5 x i8]* %foo, i32 0, i32 %i.0 ; <i8*> [#uses=1] + %tmp = load i8* %tmp ; <i8> [#uses=1] + %tmp5 = icmp eq i8 %tmp, 0 ; <i1> [#uses=1] + br i1 %tmp5, label %bb6, label %bb + +bb6: ; preds = %cond_next + br label %return + +return: ; preds = %bb6 + ret i32 %i.0 +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/2007-01-08-X86-64-Pointer.ll b/llvm/test/Transforms/IndVarsSimplify/2007-01-08-X86-64-Pointer.ll new file mode 100644 index 00000000000..028e81f61cb --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/2007-01-08-X86-64-Pointer.ll @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s | llc -march=x86-64 | grep '(%rdi,%rax,8)' && +; RUN: llvm-as < %s | llc -march=x86-64 | not grep 'addq.*8' + +define void %foo(double* %y) { +entry: + br label %bb + +bb: + %i = phi i64 [ 0, %entry ], [ %k, %bb ] + %j = getelementptr double* %y, i64 %i + store double 0.000000e+00, double* %j + %k = add i64 %i, 1 + %n = icmp eq i64 %k, 0 + br i1 %n, label %return, label %bb + +return: + ret void +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/complex-scev.ll b/llvm/test/Transforms/IndVarsSimplify/complex-scev.ll new file mode 100644 index 00000000000..773d71a20ca --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/complex-scev.ll @@ -0,0 +1,28 @@ +; The i induction variable looks like a wrap-around, but it really is just +; a simple affine IV. Make sure that indvars eliminates it. + +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep phi | wc -l | grep 1 + +void %foo() { +entry: + br label %bb6 + +bb6: ; preds = %cond_true, %entry + %j.0 = phi int [ 1, %entry ], [ %tmp5, %cond_true ] ; <int> [#uses=3] + %i.0 = phi int [ 0, %entry ], [ %j.0, %cond_true ] ; <int> [#uses=1] + %tmp7 = call int (...)* %foo2( ) ; <int> [#uses=1] + %tmp = setne int %tmp7, 0 ; <bool> [#uses=1] + br bool %tmp, label %cond_true, label %return + +cond_true: ; preds = %bb6 + %tmp2 = call int (...)* %bar( int %i.0, int %j.0 ) ; <int> [#uses=0] + %tmp5 = add int %j.0, 1 ; <int> [#uses=1] + br label %bb6 + +return: ; preds = %bb6 + ret void +} + +declare int %bar(...) + +declare int %foo2(...) diff --git a/llvm/test/Transforms/IndVarsSimplify/dg.exp b/llvm/test/Transforms/IndVarsSimplify/dg.exp new file mode 100644 index 00000000000..142de8a6c8f --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/dg.exp @@ -0,0 +1,3 @@ +load_lib llvm-dg.exp + +llvm-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]] $objdir $srcdir $subdir $target_triplet $llvmgcc $llvmgxx $prcontext $llvmgcc_version diff --git a/llvm/test/Transforms/IndVarsSimplify/exit_value_tests.llx b/llvm/test/Transforms/IndVarsSimplify/exit_value_tests.llx new file mode 100644 index 00000000000..7d5d3668640 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/exit_value_tests.llx @@ -0,0 +1,102 @@ +; Test that we can evaluate the exit values of various expression types. Since +; these loops all have predictable exit values we can replace the use outside +; of the loop with a closed-form computation, making the loop dead. +; +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -adce -simplifycfg | llvm-dis | not grep br + +int %polynomial_constant() { + br label %Loop +Loop: + %A1 = phi int [0, %0], [%A2, %Loop] + %B1 = phi int [0, %0], [%B2, %Loop] + %A2 = add int %A1, 1 + %B2 = add int %B1, %A1 + + %C = seteq int %A1, 1000 + br bool %C, label %Out, label %Loop +Out: + ret int %B2 +} + +int %NSquare(int %N) { + br label %Loop +Loop: + %X = phi int [0, %0], [%X2, %Loop] + %X2 = add int %X, 1 + %c = seteq int %X, %N + br bool %c, label %Out, label %Loop +Out: + %Y = mul int %X, %X + ret int %Y +} + +int %NSquareOver2(int %N) { + br label %Loop +Loop: + %X = phi int [0, %0], [%X2, %Loop] + %Y = phi int [15, %0], [%Y2, %Loop] ;; include offset of 15 for yuks + + %Y2 = add int %Y, %X + + %X2 = add int %X, 1 + %c = seteq int %X, %N + br bool %c, label %Out, label %Loop +Out: + ret int %Y2 +} + +int %strength_reduced() { + br label %Loop +Loop: + %A1 = phi int [0, %0], [%A2, %Loop] + %B1 = phi int [0, %0], [%B2, %Loop] + %A2 = add int %A1, 1 + %B2 = add int %B1, %A1 + + %C = seteq int %A1, 1000 + br bool %C, label %Out, label %Loop +Out: + ret int %B2 +} + +int %chrec_equals() { +entry: + br label %no_exit +no_exit: + %i0 = phi int [ 0, %entry ], [ %i1, %no_exit ] + %ISq = mul int %i0, %i0 + %i1 = add int %i0, 1 + %tmp.1 = setne int %ISq, 10000 ; while (I*I != 1000) + br bool %tmp.1, label %no_exit, label %loopexit +loopexit: + ret int %i1 +} + +;; We should recognize B1 as being a recurrence, allowing us to compute the +;; trip count and eliminate the loop. +short %cast_chrec_test() { + br label %Loop +Loop: + %A1 = phi int [0, %0], [%A2, %Loop] + %B1 = cast int %A1 to short + %A2 = add int %A1, 1 + + %C = seteq short %B1, 1000 + br bool %C, label %Out, label %Loop +Out: + ret short %B1 +} + +uint %linear_div_fold() { ;; for (i = 4; i != 68; i += 8) (exit with i/2) +entry: + br label %loop +loop: + %i = phi uint [ 4, %entry ], [ %i.next, %loop ] + %i.next = add uint %i, 8 + %RV = div uint %i, 2 + %c = setne uint %i, 68 + br bool %c, label %loop, label %loopexit +loopexit: + ret uint %RV +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/lftr_simple.llx b/llvm/test/Transforms/IndVarsSimplify/lftr_simple.llx new file mode 100644 index 00000000000..2265e57c6a2 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/lftr_simple.llx @@ -0,0 +1,23 @@ +; LFTR should eliminate the need for the computation of i*i completely. It +; is only used to compute the exit value. +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -dce | llvm-dis | not grep mul + +%A = external global int + +implementation + +int %quadratic_setlt() { ;; for (i = 7; i*i < 1000; ++i) +entry: + br label %loop +loop: + %i = phi int [ 7, %entry ], [ %i.next, %loop ] + %i.next = add int %i, 1 + store int %i, int* %A + + %i2 = mul int %i, %i + %c = setlt int %i2, 1000 + br bool %c, label %loop, label %loopexit +loopexit: + ret int %i +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/loop_evaluate_1.ll b/llvm/test/Transforms/IndVarsSimplify/loop_evaluate_1.ll new file mode 100644 index 00000000000..ead9b916a23 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/loop_evaluate_1.ll @@ -0,0 +1,21 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -adce -simplifycfg | llvm-dis | not grep br +; +; Testcase distilled from 256.bzip2 + +int %main() { +entry: + br label %loopentry + +loopentry: ; preds = %entry, %loopentry + %indvar1 = phi uint [ 0, %entry ], [ %indvar.next2, %loopentry ] ; <uint> [#uses=1] + %h.0 = phi int [ %tmp.2, %loopentry ], [ 4, %entry ] ; <int> [#uses=1] + %tmp.1 = mul int %h.0, 3 ; <int> [#uses=1] + %tmp.2 = add int %tmp.1, 1 ; <int> [#uses=1] + %indvar.next2 = add uint %indvar1, 1 ; <uint> [#uses=2] + %exitcond3 = setne uint %indvar.next2, 4 ; <bool> [#uses=1] + br bool %exitcond3, label %loopentry, label %loopexit + +loopexit: ; preds = %loopentry + ret int %tmp.2 +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/pointer-indvars.ll b/llvm/test/Transforms/IndVarsSimplify/pointer-indvars.ll new file mode 100644 index 00000000000..57f7d2470f1 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/pointer-indvars.ll @@ -0,0 +1,14 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep indvar + +%G = global int* null + +%Array = external global [40 x int] + +void %test() { + br label %Loop +Loop: + %X = phi int* [getelementptr ([40 x int]* %Array, long 0, long 0), %0], [%X.next, %Loop] + %X.next = getelementptr int* %X, long 1 + store int* %X, int** %G + br label %Loop +} diff --git a/llvm/test/Transforms/IndVarsSimplify/subtract.ll b/llvm/test/Transforms/IndVarsSimplify/subtract.ll new file mode 100644 index 00000000000..9cff198ff5a --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/subtract.ll @@ -0,0 +1,12 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars | llvm-dis | grep indvar + +%G = global long 0 + +void %test(long %V) { + br label %Loop +Loop: + %X = phi long [1, %0], [%X.next, %Loop] + %X.next = sub long %X, %V + store long %X, long* %G + br label %Loop +} diff --git a/llvm/test/Transforms/IndVarsSimplify/tripcount_compute.llx b/llvm/test/Transforms/IndVarsSimplify/tripcount_compute.llx new file mode 100644 index 00000000000..733fa1d3ef8 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/tripcount_compute.llx @@ -0,0 +1,90 @@ +; These tests ensure that we can compute the trip count of various forms of +; loops. If the trip count of the loop is computable, then we will know what +; the exit value of the loop will be for some value, allowing us to substitute +; it directly into users outside of the loop, making the loop dead. +; +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -adce -simplifycfg | llvm-dis | not grep br + +int %linear_setne() { ;; for (i = 0; i != 100; ++i) +entry: + br label %loop +loop: + %i = phi int [ 0, %entry ], [ %i.next, %loop ] + %i.next = add int %i, 1 + %c = setne int %i, 100 + br bool %c, label %loop, label %loopexit +loopexit: + ret int %i +} + +int %linear_setne_2() { ;; for (i = 0; i != 100; i += 2) +entry: + br label %loop +loop: + %i = phi int [ 0, %entry ], [ %i.next, %loop ] + %i.next = add int %i, 2 + %c = setne int %i, 100 + br bool %c, label %loop, label %loopexit +loopexit: + ret int %i +} + + +int %linear_setne_overflow() { ;; for (i = 1024; i != 0; i += 1024) +entry: + br label %loop +loop: + %i = phi int [ 1024, %entry ], [ %i.next, %loop ] + %i.next = add int %i, 1024 + %c = setne int %i, 0 + br bool %c, label %loop, label %loopexit +loopexit: + ret int %i +} + +int %linear_setlt() { ;; for (i = 0; i < 100; ++i) +entry: + br label %loop +loop: + %i = phi int [ 0, %entry ], [ %i.next, %loop ] + %i.next = add int %i, 1 + %c = setlt int %i, 100 + br bool %c, label %loop, label %loopexit +loopexit: + ret int %i +} + +int %quadratic_setlt() { ;; for (i = 7; i*i < 1000; i+=3) +entry: + br label %loop +loop: + %i = phi int [ 7, %entry ], [ %i.next, %loop ] + %i.next = add int %i, 3 + %i2 = mul int %i, %i + %c = setlt int %i2, 1000 + br bool %c, label %loop, label %loopexit +loopexit: + ret int %i +} + +;; Chained loop test - The exit value of the second loop depends on the exit +;; value of the first being computed. +int %chained() { +entry: + br label %loop +loop: ;; for (i = 0; i != 100; ++i) + %i = phi int [ 0, %entry ], [ %i.next, %loop ] + %i.next = add int %i, 1 + %c = setne int %i, 100 + br bool %c, label %loop, label %loopexit +loopexit: + br label %loop2 +loop2: ;; for (j = i; j != 200; ++j) + %j = phi int [ %i, %loopexit ], [ %j.next, %loop2 ] + %j.next = add int %j, 1 + %c2 = setne int %j, 200 + br bool %c2, label %loop2, label %loopexit2 +loopexit2: + ret int %j +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/tripcount_infinite.llx b/llvm/test/Transforms/IndVarsSimplify/tripcount_infinite.llx new file mode 100644 index 00000000000..8a7b27c3b29 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/tripcount_infinite.llx @@ -0,0 +1,32 @@ +; These tests have an infinite trip count. We obviously shouldn't remove the +; loops! :) +; +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -adce -simplifycfg | llvm-dis | grep icmp | wc -l > %t2 +; RUN: llvm-upgrade < %s | llvm-as | llvm-dis | grep icmp | wc -l > %t1 +; RUN: diff %t1 %t2 + +int %infinite_linear() { ;; test for (i = 1; i != 100; i += 2) +entry: + br label %loop +loop: + %i = phi int [ 1, %entry ], [ %i.next, %loop ] + %i.next = add int %i, 2 + %c = setne int %i, 100 + br bool %c, label %loop, label %loopexit +loopexit: + ret int %i +} + +int %infinite_quadratic() { ;; test for (i = 1; i*i != 63; ++i) +entry: + br label %loop +loop: + %i = phi int [ 1, %entry ], [ %i.next, %loop ] + %isquare = mul int %i, %i + %i.next = add int %i, 1 + %c = setne int %isquare, 63 + br bool %c, label %loop, label %loopexit +loopexit: + ret int %i +} + diff --git a/llvm/test/Transforms/IndVarsSimplify/variable-stride-ivs.ll b/llvm/test/Transforms/IndVarsSimplify/variable-stride-ivs.ll new file mode 100644 index 00000000000..d464cfa0640 --- /dev/null +++ b/llvm/test/Transforms/IndVarsSimplify/variable-stride-ivs.ll @@ -0,0 +1,41 @@ +; RUN: llvm-upgrade < %s | llvm-as | opt -indvars -instcombine | llvm-dis | grep 'store i32 0' +; Test that -indvars can reduce variable stride IVs. If it can reduce variable +; stride iv's, it will make %iv. and %m.0.0 isomorphic to each other without +; cycles, allowing the tmp.21 subtraction to be eliminated. + +void %vnum_test8(int* %data) { +entry: + %tmp.1 = getelementptr int* %data, int 3 ; <int*> [#uses=1] + %tmp.2 = load int* %tmp.1 ; <int> [#uses=2] + %tmp.4 = getelementptr int* %data, int 4 ; <int*> [#uses=1] + %tmp.5 = load int* %tmp.4 ; <int> [#uses=2] + %tmp.8 = getelementptr int* %data, int 2 ; <int*> [#uses=1] + %tmp.9 = load int* %tmp.8 ; <int> [#uses=3] + %tmp.125 = setgt int %tmp.2, 0 ; <bool> [#uses=1] + br bool %tmp.125, label %no_exit.preheader, label %return + +no_exit.preheader: ; preds = %entry + %tmp.16 = getelementptr int* %data, int %tmp.9 ; <int*> [#uses=1] + br label %no_exit + +no_exit: ; preds = %no_exit, %no_exit.preheader + %iv.ui = phi uint [ 0, %no_exit.preheader ], [ %iv..inc.ui, %no_exit ] ; <uint> [#uses=1] + %iv. = phi int [ %tmp.5, %no_exit.preheader ], [ %iv..inc, %no_exit ] ; <int> [#uses=2] + %m.0.0 = phi int [ %tmp.5, %no_exit.preheader ], [ %tmp.24, %no_exit ] ; <int> [#uses=2] + store int 2, int* %tmp.16 + %tmp.21 = sub int %m.0.0, %iv. ; <int> [#uses=1] + store int %tmp.21, int* %data + %tmp.24 = add int %m.0.0, %tmp.9 ; <int> [#uses=1] + %iv..inc = add int %tmp.9, %iv. ; <int> [#uses=1] + %iv..inc.ui = add uint %iv.ui, 1 ; <uint> [#uses=2] + %iv..inc1 = cast uint %iv..inc.ui to int ; <int> [#uses=1] + %tmp.12 = setlt int %iv..inc1, %tmp.2 ; <bool> [#uses=1] + br bool %tmp.12, label %no_exit, label %return.loopexit + +return.loopexit: ; preds = %no_exit + br label %return + +return: ; preds = %return.loopexit, %entry + ret void +} + |