From 63faed5b8e4f2755f127fcb8aa440480c0649327 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 14 Apr 2012 13:54:10 +0000 Subject: Vendor import of llvm trunk r154661: http://llvm.org/svn/llvm-project/llvm/trunk@r154661 --- test/Transforms/ADCE/dg.exp | 3 - test/Transforms/ADCE/lit.local.cfg | 1 + test/Transforms/ArgumentPromotion/dg.exp | 3 - test/Transforms/ArgumentPromotion/lit.local.cfg | 1 + test/Transforms/BBVectorize/cycle.ll | 112 ++++++++ test/Transforms/BBVectorize/func-alias.ll | 244 +++++++++++++++++ test/Transforms/BBVectorize/ld1.ll | 41 +++ test/Transforms/BBVectorize/lit.local.cfg | 1 + test/Transforms/BBVectorize/loop1.ll | 93 +++++++ test/Transforms/BBVectorize/mem-op-depth.ll | 22 ++ test/Transforms/BBVectorize/req-depth.ll | 17 ++ test/Transforms/BBVectorize/search-limit.ll | 46 ++++ test/Transforms/BBVectorize/simple-int.ll | 103 +++++++ test/Transforms/BBVectorize/simple-ldstr.ll | 110 ++++++++ test/Transforms/BBVectorize/simple.ll | 152 +++++++++++ test/Transforms/BlockPlacement/dg.exp | 3 - test/Transforms/BlockPlacement/lit.local.cfg | 1 + test/Transforms/CodeExtractor/dg.exp | 3 - test/Transforms/CodeExtractor/lit.local.cfg | 1 + test/Transforms/CodeGenPrepare/dg.exp | 3 - test/Transforms/CodeGenPrepare/lit.local.cfg | 1 + test/Transforms/ConstProp/2007-11-23-cttz.ll | 4 +- test/Transforms/ConstProp/basictest.ll | 11 + test/Transforms/ConstProp/bswap.ll | 18 +- test/Transforms/ConstProp/calls.ll | 88 ++++++ test/Transforms/ConstProp/dg.exp | 3 - test/Transforms/ConstProp/lit.local.cfg | 1 + test/Transforms/ConstantMerge/dg.exp | 3 - test/Transforms/ConstantMerge/linker-private.ll | 23 ++ test/Transforms/ConstantMerge/lit.local.cfg | 1 + .../Transforms/CorrelatedValuePropagation/basic.ll | 101 ++++++- test/Transforms/CorrelatedValuePropagation/dg.exp | 3 - .../CorrelatedValuePropagation/lit.local.cfg | 1 + .../Transforms/CorrelatedValuePropagation/range.ll | 43 +++ test/Transforms/DeadArgElim/deadexternal.ll | 4 +- test/Transforms/DeadArgElim/dg.exp | 3 - test/Transforms/DeadArgElim/lit.local.cfg | 1 + .../DeadStoreElimination/OverwriteStoreEnd.ll | 95 +++++++ test/Transforms/DeadStoreElimination/dg.exp | 3 - test/Transforms/DeadStoreElimination/dominate.ll | 25 ++ test/Transforms/DeadStoreElimination/free.ll | 36 ++- test/Transforms/DeadStoreElimination/lit.local.cfg | 1 + test/Transforms/DeadStoreElimination/pr11390.ll | 38 +++ test/Transforms/DeadStoreElimination/simple.ll | 7 + test/Transforms/EarlyCSE/basic.ll | 10 +- test/Transforms/EarlyCSE/dg.exp | 3 - test/Transforms/EarlyCSE/instsimplify-dom.ll | 19 ++ test/Transforms/EarlyCSE/lit.local.cfg | 1 + .../FunctionAttrs/2008-09-13-VolatileRead.ll | 2 +- .../FunctionAttrs/2008-12-31-NoCapture.ll | 105 -------- .../FunctionAttrs/2010-10-30-volatile.ll | 2 +- test/Transforms/FunctionAttrs/dg.exp | 3 - test/Transforms/FunctionAttrs/lit.local.cfg | 1 + test/Transforms/FunctionAttrs/nocapture.ll | 178 ++++++++++++ test/Transforms/GVN/commute.ll | 23 ++ test/Transforms/GVN/condprop.ll | 157 +++++++++-- test/Transforms/GVN/dg.exp | 3 - test/Transforms/GVN/lit.local.cfg | 1 + test/Transforms/GVN/pre-compare.ll | 68 +++++ test/Transforms/GVN/rle.ll | 34 +++ test/Transforms/GlobalDCE/2009-09-03-MDNode.ll | 264 ------------------ test/Transforms/GlobalDCE/dg.exp | 3 - test/Transforms/GlobalDCE/lit.local.cfg | 1 + .../GlobalOpt/2008-01-29-VolatileGlobal.ll | 2 +- test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll | 57 ---- test/Transforms/GlobalOpt/atomic.ll | 10 + .../GlobalOpt/constantfold-initializers.ll | 43 +++ .../GlobalOpt/ctor-list-opt-constexpr.ll | 19 +- test/Transforms/GlobalOpt/cxx-dtor.ll | 6 +- test/Transforms/GlobalOpt/deadfunction.ll | 27 ++ test/Transforms/GlobalOpt/dg.exp | 3 - test/Transforms/GlobalOpt/invariant.ll | 59 ++++ test/Transforms/GlobalOpt/invoke.ll | 27 ++ test/Transforms/GlobalOpt/lit.local.cfg | 1 + .../GlobalOpt/zeroinitializer-gep-load.ll | 11 + .../IPConstantProp/dangling-block-address.ll | 2 +- test/Transforms/IPConstantProp/dg.exp | 3 - test/Transforms/IPConstantProp/lit.local.cfg | 1 + .../IndVarSimplify/2011-09-10-widen-nsw.ll | 4 +- .../IndVarSimplify/2011-10-27-lftrnull.ll | 59 ++++ .../IndVarSimplify/2011-11-01-lftrptr.ll | 140 ++++++++++ .../IndVarSimplify/2011-11-15-multiexit.ll | 40 +++ .../IndVarSimplify/2011-11-17-selfphi.ll | 29 ++ test/Transforms/IndVarSimplify/ada-loops.ll | 1 - test/Transforms/IndVarSimplify/addrec-gep.ll | 78 ------ test/Transforms/IndVarSimplify/avoid-i0.ll | 2 +- test/Transforms/IndVarSimplify/complex-scev.ll | 31 --- test/Transforms/IndVarSimplify/dg.exp | 3 - test/Transforms/IndVarSimplify/elim-extend.ll | 2 +- .../Transforms/IndVarSimplify/gep-with-mul-base.ll | 68 ----- test/Transforms/IndVarSimplify/iv-fold.ll | 2 +- test/Transforms/IndVarSimplify/iv-zext.ll | 1 - test/Transforms/IndVarSimplify/lftr-reuse.ll | 2 +- test/Transforms/IndVarSimplify/lit.local.cfg | 1 + test/Transforms/IndVarSimplify/loop_evaluate10.ll | 8 +- test/Transforms/IndVarSimplify/loop_evaluate9.ll | 7 +- test/Transforms/IndVarSimplify/no-iv-rewrite.ll | 6 +- .../IndVarSimplify/preserve-gep-loop-variant.ll | 42 --- .../IndVarSimplify/preserve-gep-nested.ll | 76 ------ .../IndVarSimplify/preserve-gep-remainder.ll | 20 -- test/Transforms/IndVarSimplify/preserve-gep.ll | 39 --- .../IndVarSimplify/preserve-signed-wrap.ll | 1 - test/Transforms/IndVarSimplify/sink-alloca.ll | 47 +++- .../IndVarSimplify/variable-stride-ivs-0.ll | 1 - test/Transforms/Inline/2007-06-06-NoInline.ll | 46 ---- test/Transforms/Inline/2008-09-02-AlwaysInline.ll | 10 - test/Transforms/Inline/2008-10-30-AlwaysInline.ll | 14 - test/Transforms/Inline/2008-11-04-AlwaysInline.ll | 7 - test/Transforms/Inline/alloca-bonus.ll | 155 +++++++++++ test/Transforms/Inline/always-inline.ll | 125 +++++++++ test/Transforms/Inline/always_inline_dyn_alloca.ll | 15 -- test/Transforms/Inline/blockaddress.ll | 27 ++ test/Transforms/Inline/dg.exp | 3 - test/Transforms/Inline/dynamic_alloca_test.ll | 52 ++-- test/Transforms/Inline/inline-invoke-tail.ll | 8 +- test/Transforms/Inline/inline_cleanup.ll | 158 ++++++++++- test/Transforms/Inline/inline_constprop.ll | 114 +++++++- test/Transforms/Inline/inline_returns_twice.ll | 41 +++ test/Transforms/Inline/lit.local.cfg | 1 + test/Transforms/Inline/noinline-recursive-fn.ll | 43 ++- test/Transforms/Inline/ptr-diff.ll | 58 ++++ .../InstCombine/2003-09-09-VolatileLoadElim.ll | 2 +- .../InstCombine/2007-09-11-Trampoline.ll | 24 -- .../Transforms/InstCombine/2007-10-28-stacksave.ll | 2 +- .../InstCombine/2008-01-14-DoubleNest.ll | 24 -- .../InstCombine/2008-04-28-VolatileStore.ll | 2 +- .../2008-04-29-VolatileLoadDontMerge.ll | 6 +- .../InstCombine/2008-04-29-VolatileLoadMerge.ll | 4 +- .../InstCombine/2008-06-24-StackRestore.ll | 4 +- .../InstCombine/2008-07-08-VolatileLoadMerge.ll | 6 +- .../InstCombine/2012-01-11-OpaqueBitcastCrash.ll | 12 + test/Transforms/InstCombine/2012-02-13-FCmp.ll | 35 +++ test/Transforms/InstCombine/2012-02-28-ICmp.ll | 19 ++ .../InstCombine/2012-03-10-InstCombine.ll | 35 +++ .../InstCombine/2012-3-15-or-xor-constant.ll | 12 + test/Transforms/InstCombine/LandingPadClauses.ll | 52 ++++ test/Transforms/InstCombine/align-external.ll | 13 +- test/Transforms/InstCombine/alloca.ll | 44 +++ test/Transforms/InstCombine/apint-shl-trunc.ll | 15 +- test/Transforms/InstCombine/bitcount.ll | 8 +- test/Transforms/InstCombine/constant-fold-gep.ll | 6 +- test/Transforms/InstCombine/crash.ll | 15 +- test/Transforms/InstCombine/dg.exp | 3 - test/Transforms/InstCombine/extractvalue.ll | 6 +- test/Transforms/InstCombine/fold-sqrt-sqrtf.ll | 17 ++ test/Transforms/InstCombine/icmp.ll | 84 +++++- test/Transforms/InstCombine/intrinsics.ll | 46 ++-- test/Transforms/InstCombine/lit.local.cfg | 1 + test/Transforms/InstCombine/mul.ll | 80 +++++- test/Transforms/InstCombine/overflow.ll | 22 ++ test/Transforms/InstCombine/pr12251.ll | 15 ++ test/Transforms/InstCombine/select.ll | 20 ++ test/Transforms/InstCombine/sext.ll | 8 +- test/Transforms/InstCombine/shift.ll | 72 +++++ test/Transforms/InstCombine/sign-test-and-or.ll | 100 +++++++ test/Transforms/InstCombine/sub-xor.ll | 37 +++ test/Transforms/InstCombine/sub.ll | 26 ++ test/Transforms/InstCombine/vec_shuffle.ll | 46 ++++ test/Transforms/InstCombine/vector_gep1.ll | 37 +++ test/Transforms/InstCombine/volatile_store.ll | 4 +- .../InstSimplify/2011-10-27-BinOpCrash.ll | 12 + .../InstSimplify/2011-11-23-MaskedBitsCrash.ll | 17 ++ test/Transforms/InstSimplify/AndOrXor.ll | 22 ++ test/Transforms/InstSimplify/compare.ll | 275 +++++++++++++++++++ test/Transforms/InstSimplify/dg.exp | 3 - test/Transforms/InstSimplify/lit.local.cfg | 1 + test/Transforms/InstSimplify/phi.ll | 22 ++ test/Transforms/InstSimplify/ptr_diff.ll | 48 ++++ test/Transforms/InstSimplify/reassociate.ll | 9 + test/Transforms/InstSimplify/undef.ll | 28 ++ test/Transforms/InstSimplify/vector_gep.ll | 8 + test/Transforms/Internalize/dg.exp | 3 - test/Transforms/Internalize/lit.local.cfg | 1 + .../Transforms/JumpThreading/2011-04-14-InfLoop.ll | 2 +- test/Transforms/JumpThreading/crash.ll | 2 +- test/Transforms/JumpThreading/dg.exp | 3 - test/Transforms/JumpThreading/lit.local.cfg | 1 + .../JumpThreading/no-irreducible-loops.ll | 4 +- test/Transforms/JumpThreading/thread-loads.ll | 48 +++- test/Transforms/LCSSA/dg.exp | 3 - test/Transforms/LCSSA/lit.local.cfg | 1 + test/Transforms/LICM/2007-05-22-VolatileSink.ll | 4 +- .../LICM/2011-04-06-HoistMissedASTUpdate.ll | 2 +- test/Transforms/LICM/crash.ll | 2 +- test/Transforms/LICM/dg.exp | 3 - test/Transforms/LICM/hoist-invariant-load.ll | 39 +++ test/Transforms/LICM/lit.local.cfg | 1 + test/Transforms/LICM/scalar_promote.ll | 4 +- test/Transforms/LICM/speculate.ll | 167 ++++++++++++ test/Transforms/LoopDeletion/dg.exp | 3 - test/Transforms/LoopDeletion/lit.local.cfg | 1 + test/Transforms/LoopIdiom/dg.exp | 3 - test/Transforms/LoopIdiom/lit.local.cfg | 1 + test/Transforms/LoopRotate/alloca.ll | 33 +++ test/Transforms/LoopRotate/dbgvalue.ll | 48 +++- test/Transforms/LoopRotate/dg.exp | 3 - test/Transforms/LoopRotate/lit.local.cfg | 1 + test/Transforms/LoopRotate/simplifylatch.ll | 39 +++ .../LoopSimplify/2011-12-14-LandingpadHeader.ll | 45 ++++ .../LoopSimplify/2012-03-20-indirectbr.ll | 41 +++ test/Transforms/LoopSimplify/dg.exp | 3 - test/Transforms/LoopSimplify/lit.local.cfg | 1 + .../LoopStrengthReduce/2008-08-13-CmpStride.ll | 4 +- .../2011-12-19-PostincQuadratic.ll | 39 +++ .../LoopStrengthReduce/2012-01-02-nopreheader.ll | 88 ++++++ .../LoopStrengthReduce/2012-01-16-nopreheader.ll | 113 ++++++++ .../LoopStrengthReduce/2012-03-15-nopreheader.ll | 155 +++++++++++ .../LoopStrengthReduce/2012-03-26-constexpr.ll | 49 ++++ .../LoopStrengthReduce/ARM/ivchain-ARM.ll | 292 ++++++++++++++++++++ .../LoopStrengthReduce/ARM/lit.local.cfg | 6 + .../X86/2011-11-29-postincphi.ll | 36 +++ .../LoopStrengthReduce/X86/2011-12-04-loserreg.ll | 96 +++++++ .../LoopStrengthReduce/X86/2012-01-13-phielim.ll | 92 +++++++ test/Transforms/LoopStrengthReduce/X86/dg.exp | 5 - .../LoopStrengthReduce/X86/ivchain-X86.ll | 300 +++++++++++++++++++++ .../LoopStrengthReduce/X86/ivchain-stress-X86.ll | 96 +++++++ .../LoopStrengthReduce/X86/lit.local.cfg | 6 + test/Transforms/LoopStrengthReduce/addrec-gep.ll | 82 ++++++ test/Transforms/LoopStrengthReduce/dg.exp | 3 - .../LoopStrengthReduce/dominate-assert.ll | 70 +++++ .../LoopStrengthReduce/exit_compare_live_range.ll | 2 +- test/Transforms/LoopStrengthReduce/ivchain.ll | 43 +++ test/Transforms/LoopStrengthReduce/lit.local.cfg | 1 + .../LoopStrengthReduce/post-inc-icmpzero.ll | 10 +- test/Transforms/LoopStrengthReduce/pr12018.ll | 38 +++ test/Transforms/LoopStrengthReduce/pr12048.ll | 38 +++ test/Transforms/LoopStrengthReduce/pr3399.ll | 2 +- .../preserve-gep-loop-variant.ll | 42 +++ .../Transforms/LoopUnroll/2011-08-09-IVSimplify.ll | 2 +- .../LoopUnroll/2012-04-09-unroll-indirectbr.ll | 40 +++ test/Transforms/LoopUnroll/dg.exp | 3 - test/Transforms/LoopUnroll/lit.local.cfg | 1 + .../LoopUnroll/partial-unroll-optsize.ll | 35 +++ test/Transforms/LoopUnroll/pr11361.ll | 42 +++ test/Transforms/LoopUnroll/runtime-loop.ll | 109 ++++++++ test/Transforms/LoopUnroll/runtime-loop1.ll | 30 +++ test/Transforms/LoopUnroll/runtime-loop2.ll | 31 +++ test/Transforms/LoopUnroll/runtime-loop3.ll | 44 +++ test/Transforms/LoopUnroll/unloop.ll | 41 +++ .../LoopUnswitch/2011-11-18-SimpleSwitch.ll | 91 +++++++ .../2011-11-18-TwoSwitches-Threshold.ll | 84 ++++++ .../LoopUnswitch/2011-11-18-TwoSwitches.ll | 138 ++++++++++ .../LoopUnswitch/2012-04-02-IndirectBr.ll | 41 +++ test/Transforms/LoopUnswitch/dg.exp | 3 - test/Transforms/LoopUnswitch/lit.local.cfg | 1 + test/Transforms/LowerAtomic/dg.exp | 3 - test/Transforms/LowerAtomic/lit.local.cfg | 1 + test/Transforms/LowerExpectIntrinsic/dg.exp | 3 - test/Transforms/LowerExpectIntrinsic/lit.local.cfg | 1 + test/Transforms/LowerInvoke/dg.exp | 3 - test/Transforms/LowerInvoke/lit.local.cfg | 1 + test/Transforms/LowerSwitch/dg.exp | 3 - test/Transforms/LowerSwitch/lit.local.cfg | 1 + .../Mem2Reg/2007-08-27-VolatileLoadsStores.ll | 8 +- test/Transforms/Mem2Reg/dg.exp | 3 - test/Transforms/Mem2Reg/lit.local.cfg | 1 + test/Transforms/MemCpyOpt/dg.exp | 3 - test/Transforms/MemCpyOpt/form-memset.ll | 30 ++- test/Transforms/MemCpyOpt/lit.local.cfg | 1 + test/Transforms/MemCpyOpt/memcpy.ll | 20 +- .../Transforms/MergeFunc/2011-02-08-RemoveEqual.ll | 20 +- test/Transforms/MergeFunc/dg.exp | 3 - test/Transforms/MergeFunc/lit.local.cfg | 1 + test/Transforms/ObjCARC/apelim.ll | 53 ++++ test/Transforms/ObjCARC/basic.ll | 216 ++++++++++++++- .../ObjCARC/contract-storestrong-ivar.ll | 2 +- test/Transforms/ObjCARC/contract-storestrong.ll | 6 +- test/Transforms/ObjCARC/contract.ll | 18 ++ test/Transforms/ObjCARC/dg.exp | 3 - test/Transforms/ObjCARC/invoke.ll | 145 ++++++++++ test/Transforms/ObjCARC/lit.local.cfg | 1 + test/Transforms/ObjCARC/nested.ll | 141 +++++++++- test/Transforms/ObjCARC/no-objc-arc-exceptions.ll | 122 +++++++++ test/Transforms/ObjCARC/pointer-types.ll | 31 +++ test/Transforms/ObjCARC/pr12270.ll | 21 ++ test/Transforms/ObjCARC/retain-block-alloca.ll | 46 +++- test/Transforms/ObjCARC/retain-block-load.ll | 51 ++++ test/Transforms/ObjCARC/retain-block.ll | 138 ++++++++++ test/Transforms/ObjCARC/retain-not-declared.ll | 2 +- test/Transforms/PhaseOrdering/dg.exp | 3 - test/Transforms/PhaseOrdering/lit.local.cfg | 1 + test/Transforms/PruneEH/dg.exp | 3 - test/Transforms/PruneEH/lit.local.cfg | 1 + test/Transforms/Reassociate/dg.exp | 3 - test/Transforms/Reassociate/lit.local.cfg | 1 + test/Transforms/SCCP/2008-05-23-UndefCallFold.ll | 4 +- test/Transforms/SCCP/2009-01-14-IPSCCP-Invoke.ll | 4 - test/Transforms/SCCP/dg.exp | 3 - test/Transforms/SCCP/lit.local.cfg | 1 + test/Transforms/SCCP/phitest.ll | 20 -- .../ScalarRepl/2009-03-05-Aggre2Scalar-dbg.ll | 184 ------------- .../ScalarRepl/2011-10-22-VectorCrash.ll | 19 ++ .../ScalarRepl/2011-11-11-EmptyStruct.ll | 26 ++ test/Transforms/ScalarRepl/debuginfo.ll | 107 -------- test/Transforms/ScalarRepl/dg.exp | 3 - test/Transforms/ScalarRepl/lit.local.cfg | 1 + test/Transforms/ScalarRepl/negative-memset.ll | 20 ++ test/Transforms/ScalarRepl/phi-cycle.ll | 77 ++++++ test/Transforms/ScalarRepl/volatile.ll | 4 +- ...2009-01-19-UnconditionalTrappingConstantExpr.ll | 12 +- .../SimplifyCFG/2010-10-24-OnlyUnwindInEntry.ll | 6 - test/Transforms/SimplifyCFG/SpeculativeExec.ll | 31 ++- .../SimplifyCFG/branch-branch-dbginfo.ll | 70 ----- test/Transforms/SimplifyCFG/branch-fold.ll | 16 +- test/Transforms/SimplifyCFG/branch_fold_dbg.ll | 122 --------- test/Transforms/SimplifyCFG/dg.exp | 3 - .../SimplifyCFG/hoist-common-code.dbg.ll | 33 --- test/Transforms/SimplifyCFG/lit.local.cfg | 1 + test/Transforms/SimplifyCFG/multiple-phis.ll | 39 +++ .../SimplifyCFG/preserve-branchweights.ll | 88 ++++++ test/Transforms/SimplifyCFG/select-gep.ll | 4 +- test/Transforms/SimplifyCFG/switch-masked-bits.ll | 4 +- .../SimplifyCFG/switch-on-const-select.ll | 2 +- .../Transforms/SimplifyCFG/switch_formation.dbg.ll | 50 ---- .../SimplifyCFG/switch_switch_fold_dbginfo.ll | 116 -------- .../SimplifyCFG/two-entry-phi-return.dbg.ll | 28 -- test/Transforms/SimplifyCFG/unreachable-blocks.ll | 28 ++ test/Transforms/SimplifyLibCalls/PR7357.ll | 2 +- test/Transforms/SimplifyLibCalls/Printf.ll | 5 +- test/Transforms/SimplifyLibCalls/StrLen.ll | 6 + test/Transforms/SimplifyLibCalls/cos.ll | 14 + test/Transforms/SimplifyLibCalls/dg.exp | 3 - test/Transforms/SimplifyLibCalls/fwrite.ll | 13 + test/Transforms/SimplifyLibCalls/lit.local.cfg | 1 + test/Transforms/SimplifyLibCalls/osx-names.ll | 30 +++ test/Transforms/Sink/basic.ll | 2 +- test/Transforms/Sink/dg.exp | 3 - test/Transforms/Sink/lit.local.cfg | 1 + test/Transforms/StripSymbols/dg.exp | 3 - test/Transforms/StripSymbols/lit.local.cfg | 1 + test/Transforms/TailCallElim/dg.exp | 3 - test/Transforms/TailCallElim/dont_reorder_load.ll | 4 +- test/Transforms/TailCallElim/lit.local.cfg | 1 + test/Transforms/TailCallElim/setjmp.ll | 2 +- test/Transforms/TailDup/X86/dg.exp | 5 - test/Transforms/TailDup/X86/lit.local.cfg | 6 + test/Transforms/TailDup/dg.exp | 3 - test/Transforms/TailDup/lit.local.cfg | 5 + 338 files changed, 8831 insertions(+), 2097 deletions(-) delete mode 100644 test/Transforms/ADCE/dg.exp create mode 100644 test/Transforms/ADCE/lit.local.cfg delete mode 100644 test/Transforms/ArgumentPromotion/dg.exp create mode 100644 test/Transforms/ArgumentPromotion/lit.local.cfg create mode 100644 test/Transforms/BBVectorize/cycle.ll create mode 100644 test/Transforms/BBVectorize/func-alias.ll create mode 100644 test/Transforms/BBVectorize/ld1.ll create mode 100644 test/Transforms/BBVectorize/lit.local.cfg create mode 100644 test/Transforms/BBVectorize/loop1.ll create mode 100644 test/Transforms/BBVectorize/mem-op-depth.ll create mode 100644 test/Transforms/BBVectorize/req-depth.ll create mode 100644 test/Transforms/BBVectorize/search-limit.ll create mode 100644 test/Transforms/BBVectorize/simple-int.ll create mode 100644 test/Transforms/BBVectorize/simple-ldstr.ll create mode 100644 test/Transforms/BBVectorize/simple.ll delete mode 100644 test/Transforms/BlockPlacement/dg.exp create mode 100644 test/Transforms/BlockPlacement/lit.local.cfg delete mode 100644 test/Transforms/CodeExtractor/dg.exp create mode 100644 test/Transforms/CodeExtractor/lit.local.cfg delete mode 100644 test/Transforms/CodeGenPrepare/dg.exp create mode 100644 test/Transforms/CodeGenPrepare/lit.local.cfg delete mode 100644 test/Transforms/ConstProp/dg.exp create mode 100644 test/Transforms/ConstProp/lit.local.cfg delete mode 100644 test/Transforms/ConstantMerge/dg.exp create mode 100644 test/Transforms/ConstantMerge/linker-private.ll create mode 100644 test/Transforms/ConstantMerge/lit.local.cfg delete mode 100644 test/Transforms/CorrelatedValuePropagation/dg.exp create mode 100644 test/Transforms/CorrelatedValuePropagation/lit.local.cfg create mode 100644 test/Transforms/CorrelatedValuePropagation/range.ll delete mode 100644 test/Transforms/DeadArgElim/dg.exp create mode 100644 test/Transforms/DeadArgElim/lit.local.cfg create mode 100644 test/Transforms/DeadStoreElimination/OverwriteStoreEnd.ll delete mode 100644 test/Transforms/DeadStoreElimination/dg.exp create mode 100644 test/Transforms/DeadStoreElimination/dominate.ll create mode 100644 test/Transforms/DeadStoreElimination/lit.local.cfg create mode 100644 test/Transforms/DeadStoreElimination/pr11390.ll delete mode 100644 test/Transforms/EarlyCSE/dg.exp create mode 100644 test/Transforms/EarlyCSE/instsimplify-dom.ll create mode 100644 test/Transforms/EarlyCSE/lit.local.cfg delete mode 100644 test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll delete mode 100644 test/Transforms/FunctionAttrs/dg.exp create mode 100644 test/Transforms/FunctionAttrs/lit.local.cfg create mode 100644 test/Transforms/FunctionAttrs/nocapture.ll create mode 100644 test/Transforms/GVN/commute.ll delete mode 100644 test/Transforms/GVN/dg.exp create mode 100644 test/Transforms/GVN/lit.local.cfg create mode 100644 test/Transforms/GVN/pre-compare.ll delete mode 100644 test/Transforms/GlobalDCE/2009-09-03-MDNode.ll delete mode 100644 test/Transforms/GlobalDCE/dg.exp create mode 100644 test/Transforms/GlobalDCE/lit.local.cfg delete mode 100644 test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll create mode 100644 test/Transforms/GlobalOpt/atomic.ll create mode 100644 test/Transforms/GlobalOpt/deadfunction.ll delete mode 100644 test/Transforms/GlobalOpt/dg.exp create mode 100644 test/Transforms/GlobalOpt/invariant.ll create mode 100644 test/Transforms/GlobalOpt/invoke.ll create mode 100644 test/Transforms/GlobalOpt/lit.local.cfg create mode 100644 test/Transforms/GlobalOpt/zeroinitializer-gep-load.ll delete mode 100644 test/Transforms/IPConstantProp/dg.exp create mode 100644 test/Transforms/IPConstantProp/lit.local.cfg create mode 100644 test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll create mode 100644 test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll create mode 100644 test/Transforms/IndVarSimplify/2011-11-15-multiexit.ll create mode 100644 test/Transforms/IndVarSimplify/2011-11-17-selfphi.ll delete mode 100644 test/Transforms/IndVarSimplify/addrec-gep.ll delete mode 100644 test/Transforms/IndVarSimplify/complex-scev.ll delete mode 100644 test/Transforms/IndVarSimplify/dg.exp delete mode 100644 test/Transforms/IndVarSimplify/gep-with-mul-base.ll create mode 100644 test/Transforms/IndVarSimplify/lit.local.cfg delete mode 100644 test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll delete mode 100644 test/Transforms/IndVarSimplify/preserve-gep-nested.ll delete mode 100644 test/Transforms/IndVarSimplify/preserve-gep-remainder.ll delete mode 100644 test/Transforms/IndVarSimplify/preserve-gep.ll delete mode 100644 test/Transforms/Inline/2007-06-06-NoInline.ll delete mode 100644 test/Transforms/Inline/2008-09-02-AlwaysInline.ll delete mode 100644 test/Transforms/Inline/2008-10-30-AlwaysInline.ll delete mode 100644 test/Transforms/Inline/2008-11-04-AlwaysInline.ll create mode 100644 test/Transforms/Inline/alloca-bonus.ll create mode 100644 test/Transforms/Inline/always-inline.ll delete mode 100644 test/Transforms/Inline/always_inline_dyn_alloca.ll create mode 100644 test/Transforms/Inline/blockaddress.ll delete mode 100644 test/Transforms/Inline/dg.exp create mode 100644 test/Transforms/Inline/inline_returns_twice.ll create mode 100644 test/Transforms/Inline/lit.local.cfg create mode 100644 test/Transforms/Inline/ptr-diff.ll delete mode 100644 test/Transforms/InstCombine/2007-09-11-Trampoline.ll delete mode 100644 test/Transforms/InstCombine/2008-01-14-DoubleNest.ll create mode 100644 test/Transforms/InstCombine/2012-01-11-OpaqueBitcastCrash.ll create mode 100644 test/Transforms/InstCombine/2012-02-13-FCmp.ll create mode 100644 test/Transforms/InstCombine/2012-02-28-ICmp.ll create mode 100644 test/Transforms/InstCombine/2012-03-10-InstCombine.ll create mode 100644 test/Transforms/InstCombine/2012-3-15-or-xor-constant.ll delete mode 100644 test/Transforms/InstCombine/dg.exp create mode 100644 test/Transforms/InstCombine/fold-sqrt-sqrtf.ll create mode 100644 test/Transforms/InstCombine/lit.local.cfg create mode 100644 test/Transforms/InstCombine/pr12251.ll create mode 100644 test/Transforms/InstCombine/sub-xor.ll create mode 100644 test/Transforms/InstCombine/vector_gep1.ll create mode 100644 test/Transforms/InstSimplify/2011-10-27-BinOpCrash.ll create mode 100644 test/Transforms/InstSimplify/2011-11-23-MaskedBitsCrash.ll create mode 100644 test/Transforms/InstSimplify/AndOrXor.ll delete mode 100644 test/Transforms/InstSimplify/dg.exp create mode 100644 test/Transforms/InstSimplify/lit.local.cfg create mode 100644 test/Transforms/InstSimplify/phi.ll create mode 100644 test/Transforms/InstSimplify/ptr_diff.ll create mode 100644 test/Transforms/InstSimplify/vector_gep.ll delete mode 100644 test/Transforms/Internalize/dg.exp create mode 100644 test/Transforms/Internalize/lit.local.cfg delete mode 100644 test/Transforms/JumpThreading/dg.exp create mode 100644 test/Transforms/JumpThreading/lit.local.cfg delete mode 100644 test/Transforms/LCSSA/dg.exp create mode 100644 test/Transforms/LCSSA/lit.local.cfg delete mode 100644 test/Transforms/LICM/dg.exp create mode 100644 test/Transforms/LICM/hoist-invariant-load.ll create mode 100644 test/Transforms/LICM/lit.local.cfg create mode 100644 test/Transforms/LICM/speculate.ll delete mode 100644 test/Transforms/LoopDeletion/dg.exp create mode 100644 test/Transforms/LoopDeletion/lit.local.cfg delete mode 100644 test/Transforms/LoopIdiom/dg.exp create mode 100644 test/Transforms/LoopIdiom/lit.local.cfg create mode 100644 test/Transforms/LoopRotate/alloca.ll delete mode 100644 test/Transforms/LoopRotate/dg.exp create mode 100644 test/Transforms/LoopRotate/lit.local.cfg create mode 100644 test/Transforms/LoopRotate/simplifylatch.ll create mode 100644 test/Transforms/LoopSimplify/2011-12-14-LandingpadHeader.ll create mode 100644 test/Transforms/LoopSimplify/2012-03-20-indirectbr.ll delete mode 100644 test/Transforms/LoopSimplify/dg.exp create mode 100644 test/Transforms/LoopSimplify/lit.local.cfg create mode 100644 test/Transforms/LoopStrengthReduce/2011-12-19-PostincQuadratic.ll create mode 100644 test/Transforms/LoopStrengthReduce/2012-01-02-nopreheader.ll create mode 100644 test/Transforms/LoopStrengthReduce/2012-01-16-nopreheader.ll create mode 100644 test/Transforms/LoopStrengthReduce/2012-03-15-nopreheader.ll create mode 100644 test/Transforms/LoopStrengthReduce/2012-03-26-constexpr.ll create mode 100644 test/Transforms/LoopStrengthReduce/ARM/ivchain-ARM.ll create mode 100644 test/Transforms/LoopStrengthReduce/ARM/lit.local.cfg create mode 100644 test/Transforms/LoopStrengthReduce/X86/2011-11-29-postincphi.ll create mode 100644 test/Transforms/LoopStrengthReduce/X86/2011-12-04-loserreg.ll create mode 100644 test/Transforms/LoopStrengthReduce/X86/2012-01-13-phielim.ll delete mode 100644 test/Transforms/LoopStrengthReduce/X86/dg.exp create mode 100644 test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll create mode 100644 test/Transforms/LoopStrengthReduce/X86/ivchain-stress-X86.ll create mode 100644 test/Transforms/LoopStrengthReduce/X86/lit.local.cfg create mode 100644 test/Transforms/LoopStrengthReduce/addrec-gep.ll delete mode 100644 test/Transforms/LoopStrengthReduce/dg.exp create mode 100644 test/Transforms/LoopStrengthReduce/dominate-assert.ll create mode 100644 test/Transforms/LoopStrengthReduce/ivchain.ll create mode 100644 test/Transforms/LoopStrengthReduce/lit.local.cfg create mode 100644 test/Transforms/LoopStrengthReduce/pr12018.ll create mode 100644 test/Transforms/LoopStrengthReduce/pr12048.ll create mode 100644 test/Transforms/LoopStrengthReduce/preserve-gep-loop-variant.ll create mode 100644 test/Transforms/LoopUnroll/2012-04-09-unroll-indirectbr.ll delete mode 100644 test/Transforms/LoopUnroll/dg.exp create mode 100644 test/Transforms/LoopUnroll/lit.local.cfg create mode 100644 test/Transforms/LoopUnroll/partial-unroll-optsize.ll create mode 100644 test/Transforms/LoopUnroll/pr11361.ll create mode 100644 test/Transforms/LoopUnroll/runtime-loop.ll create mode 100644 test/Transforms/LoopUnroll/runtime-loop1.ll create mode 100644 test/Transforms/LoopUnroll/runtime-loop2.ll create mode 100644 test/Transforms/LoopUnroll/runtime-loop3.ll create mode 100644 test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll create mode 100644 test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll create mode 100644 test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll create mode 100644 test/Transforms/LoopUnswitch/2012-04-02-IndirectBr.ll delete mode 100644 test/Transforms/LoopUnswitch/dg.exp create mode 100644 test/Transforms/LoopUnswitch/lit.local.cfg delete mode 100644 test/Transforms/LowerAtomic/dg.exp create mode 100644 test/Transforms/LowerAtomic/lit.local.cfg delete mode 100644 test/Transforms/LowerExpectIntrinsic/dg.exp create mode 100644 test/Transforms/LowerExpectIntrinsic/lit.local.cfg delete mode 100644 test/Transforms/LowerInvoke/dg.exp create mode 100644 test/Transforms/LowerInvoke/lit.local.cfg delete mode 100644 test/Transforms/LowerSwitch/dg.exp create mode 100644 test/Transforms/LowerSwitch/lit.local.cfg delete mode 100644 test/Transforms/Mem2Reg/dg.exp create mode 100644 test/Transforms/Mem2Reg/lit.local.cfg delete mode 100644 test/Transforms/MemCpyOpt/dg.exp create mode 100644 test/Transforms/MemCpyOpt/lit.local.cfg delete mode 100644 test/Transforms/MergeFunc/dg.exp create mode 100644 test/Transforms/MergeFunc/lit.local.cfg create mode 100644 test/Transforms/ObjCARC/apelim.ll delete mode 100644 test/Transforms/ObjCARC/dg.exp create mode 100644 test/Transforms/ObjCARC/lit.local.cfg create mode 100644 test/Transforms/ObjCARC/no-objc-arc-exceptions.ll create mode 100644 test/Transforms/ObjCARC/pointer-types.ll create mode 100644 test/Transforms/ObjCARC/pr12270.ll create mode 100644 test/Transforms/ObjCARC/retain-block-load.ll create mode 100644 test/Transforms/ObjCARC/retain-block.ll delete mode 100644 test/Transforms/PhaseOrdering/dg.exp create mode 100644 test/Transforms/PhaseOrdering/lit.local.cfg delete mode 100644 test/Transforms/PruneEH/dg.exp create mode 100644 test/Transforms/PruneEH/lit.local.cfg delete mode 100644 test/Transforms/Reassociate/dg.exp create mode 100644 test/Transforms/Reassociate/lit.local.cfg delete mode 100644 test/Transforms/SCCP/dg.exp create mode 100644 test/Transforms/SCCP/lit.local.cfg delete mode 100644 test/Transforms/SCCP/phitest.ll delete mode 100644 test/Transforms/ScalarRepl/2009-03-05-Aggre2Scalar-dbg.ll create mode 100644 test/Transforms/ScalarRepl/2011-10-22-VectorCrash.ll create mode 100644 test/Transforms/ScalarRepl/2011-11-11-EmptyStruct.ll delete mode 100644 test/Transforms/ScalarRepl/debuginfo.ll delete mode 100644 test/Transforms/ScalarRepl/dg.exp create mode 100644 test/Transforms/ScalarRepl/lit.local.cfg create mode 100644 test/Transforms/ScalarRepl/negative-memset.ll create mode 100644 test/Transforms/ScalarRepl/phi-cycle.ll delete mode 100644 test/Transforms/SimplifyCFG/2010-10-24-OnlyUnwindInEntry.ll delete mode 100644 test/Transforms/SimplifyCFG/branch-branch-dbginfo.ll delete mode 100644 test/Transforms/SimplifyCFG/branch_fold_dbg.ll delete mode 100644 test/Transforms/SimplifyCFG/dg.exp delete mode 100644 test/Transforms/SimplifyCFG/hoist-common-code.dbg.ll create mode 100644 test/Transforms/SimplifyCFG/lit.local.cfg create mode 100644 test/Transforms/SimplifyCFG/multiple-phis.ll create mode 100644 test/Transforms/SimplifyCFG/preserve-branchweights.ll delete mode 100644 test/Transforms/SimplifyCFG/switch_formation.dbg.ll delete mode 100644 test/Transforms/SimplifyCFG/switch_switch_fold_dbginfo.ll delete mode 100644 test/Transforms/SimplifyCFG/two-entry-phi-return.dbg.ll create mode 100644 test/Transforms/SimplifyCFG/unreachable-blocks.ll create mode 100644 test/Transforms/SimplifyLibCalls/cos.ll delete mode 100644 test/Transforms/SimplifyLibCalls/dg.exp create mode 100644 test/Transforms/SimplifyLibCalls/fwrite.ll create mode 100644 test/Transforms/SimplifyLibCalls/lit.local.cfg create mode 100644 test/Transforms/SimplifyLibCalls/osx-names.ll delete mode 100644 test/Transforms/Sink/dg.exp create mode 100644 test/Transforms/Sink/lit.local.cfg delete mode 100644 test/Transforms/StripSymbols/dg.exp create mode 100644 test/Transforms/StripSymbols/lit.local.cfg delete mode 100644 test/Transforms/TailCallElim/dg.exp create mode 100644 test/Transforms/TailCallElim/lit.local.cfg delete mode 100644 test/Transforms/TailDup/X86/dg.exp create mode 100644 test/Transforms/TailDup/X86/lit.local.cfg delete mode 100644 test/Transforms/TailDup/dg.exp create mode 100644 test/Transforms/TailDup/lit.local.cfg (limited to 'test/Transforms') diff --git a/test/Transforms/ADCE/dg.exp b/test/Transforms/ADCE/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/ADCE/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/ADCE/lit.local.cfg b/test/Transforms/ADCE/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/ADCE/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/ArgumentPromotion/dg.exp b/test/Transforms/ArgumentPromotion/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/ArgumentPromotion/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/ArgumentPromotion/lit.local.cfg b/test/Transforms/ArgumentPromotion/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/ArgumentPromotion/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/BBVectorize/cycle.ll b/test/Transforms/BBVectorize/cycle.ll new file mode 100644 index 000000000000..32a91ceee007 --- /dev/null +++ b/test/Transforms/BBVectorize/cycle.ll @@ -0,0 +1,112 @@ +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" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s + +; This test checks the non-trivial pairing-induced cycle avoidance. Without this cycle avoidance, the algorithm would otherwise +; want to select the pairs: +; %div77 = fdiv double %sub74, %mul76.v.r1 <-> %div125 = fdiv double %mul121, %mul76.v.r2 (div125 depends on mul117) +; %add84 = fadd double %sub83, 2.000000e+00 <-> %add127 = fadd double %mul126, 1.000000e+00 (add127 depends on div77) +; %mul95 = fmul double %sub45.v.r1, %sub36.v.r1 <-> %mul88 = fmul double %sub36.v.r1, %sub87 (mul88 depends on add84) +; %mul117 = fmul double %sub39.v.r1, %sub116 <-> %mul97 = fmul double %mul96, %sub39.v.r1 (mul97 depends on mul95) +; and so a dependency cycle would be created. + +declare double @fabs(double) nounwind readnone +define void @test1(double %a, double %b, double %c, double %add80, double %mul1, double %mul2.v.r1, double %mul73, double %sub, double %sub65, double %F.0, i32 %n.0, double %Bnm3.0, double %Bnm2.0, double %Bnm1.0, double %Anm3.0, double %Anm2.0, double %Anm1.0) { +entry: + br label %go +go: + %conv = sitofp i32 %n.0 to double + %add35 = fadd double %conv, %a + %sub36 = fadd double %add35, -1.000000e+00 + %add38 = fadd double %conv, %b + %sub39 = fadd double %add38, -1.000000e+00 + %add41 = fadd double %conv, %c + %sub42 = fadd double %add41, -1.000000e+00 + %sub45 = fadd double %add35, -2.000000e+00 + %sub48 = fadd double %add38, -2.000000e+00 + %sub51 = fadd double %add41, -2.000000e+00 + %mul52 = shl nsw i32 %n.0, 1 + %sub53 = add nsw i32 %mul52, -1 + %conv54 = sitofp i32 %sub53 to double + %sub56 = add nsw i32 %mul52, -3 + %conv57 = sitofp i32 %sub56 to double + %sub59 = add nsw i32 %mul52, -5 + %conv60 = sitofp i32 %sub59 to double + %mul61 = mul nsw i32 %n.0, %n.0 + %conv62 = sitofp i32 %mul61 to double + %mul63 = fmul double %conv62, 3.000000e+00 + %mul67 = fmul double %sub65, %conv + %add68 = fadd double %mul63, %mul67 + %add69 = fadd double %add68, 2.000000e+00 + %sub71 = fsub double %add69, %mul2.v.r1 + %sub74 = fsub double %sub71, %mul73 + %mul75 = fmul double %conv57, 2.000000e+00 + %mul76 = fmul double %mul75, %sub42 + %div77 = fdiv double %sub74, %mul76 + %mul82 = fmul double %add80, %conv + %sub83 = fsub double %mul63, %mul82 + %add84 = fadd double %sub83, 2.000000e+00 + %sub86 = fsub double %add84, %mul2.v.r1 + %sub87 = fsub double -0.000000e+00, %sub86 + %mul88 = fmul double %sub36, %sub87 + %mul89 = fmul double %mul88, %sub39 + %mul90 = fmul double %conv54, 4.000000e+00 + %mul91 = fmul double %mul90, %conv57 + %mul92 = fmul double %mul91, %sub51 + %mul93 = fmul double %mul92, %sub42 + %div94 = fdiv double %mul89, %mul93 + %mul95 = fmul double %sub45, %sub36 + %mul96 = fmul double %mul95, %sub48 + %mul97 = fmul double %mul96, %sub39 + %sub99 = fsub double %conv, %a + %sub100 = fadd double %sub99, -2.000000e+00 + %mul101 = fmul double %mul97, %sub100 + %sub103 = fsub double %conv, %b + %sub104 = fadd double %sub103, -2.000000e+00 + %mul105 = fmul double %mul101, %sub104 + %mul106 = fmul double %conv57, 8.000000e+00 + %mul107 = fmul double %mul106, %conv57 + %mul108 = fmul double %mul107, %conv60 + %sub111 = fadd double %add41, -3.000000e+00 + %mul112 = fmul double %mul108, %sub111 + %mul113 = fmul double %mul112, %sub51 + %mul114 = fmul double %mul113, %sub42 + %div115 = fdiv double %mul105, %mul114 + %sub116 = fsub double -0.000000e+00, %sub36 + %mul117 = fmul double %sub39, %sub116 + %sub119 = fsub double %conv, %c + %sub120 = fadd double %sub119, -1.000000e+00 + %mul121 = fmul double %mul117, %sub120 + %mul123 = fmul double %mul75, %sub51 + %mul124 = fmul double %mul123, %sub42 + %div125 = fdiv double %mul121, %mul124 + %mul126 = fmul double %div77, %sub + %add127 = fadd double %mul126, 1.000000e+00 + %mul128 = fmul double %add127, %Anm1.0 + %mul129 = fmul double %div94, %sub + %add130 = fadd double %div125, %mul129 + %mul131 = fmul double %add130, %sub + %mul132 = fmul double %mul131, %Anm2.0 + %add133 = fadd double %mul128, %mul132 + %mul134 = fmul double %div115, %mul1 + %mul135 = fmul double %mul134, %Anm3.0 + %add136 = fadd double %add133, %mul135 + %mul139 = fmul double %add127, %Bnm1.0 + %mul143 = fmul double %mul131, %Bnm2.0 + %add144 = fadd double %mul139, %mul143 + %mul146 = fmul double %mul134, %Bnm3.0 + %add147 = fadd double %add144, %mul146 + %div148 = fdiv double %add136, %add147 + %sub149 = fsub double %F.0, %div148 + %div150 = fdiv double %sub149, %F.0 + %call = tail call double @fabs(double %div150) nounwind readnone + %cmp = fcmp olt double %call, 0x3CB0000000000000 + %cmp152 = icmp sgt i32 %n.0, 20000 + %or.cond = or i1 %cmp, %cmp152 + br i1 %or.cond, label %done, label %go +done: + ret void +; CHECK: @test1 +; CHECK: go: +; CHECK-NEXT: %conv.v.i0.1 = insertelement <2 x i32> undef, i32 %n.0, i32 0 +; FIXME: When tree pruning is deterministic, include the entire output. +} diff --git a/test/Transforms/BBVectorize/func-alias.ll b/test/Transforms/BBVectorize/func-alias.ll new file mode 100644 index 000000000000..9d0cc07c1593 --- /dev/null +++ b/test/Transforms/BBVectorize/func-alias.ll @@ -0,0 +1,244 @@ +target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-f128:128:128-n8:16:32:64" +target triple = "x86_64-unknown-linux-gnu" +; RUN: opt < %s -basicaa -bb-vectorize -bb-vectorize-req-chain-depth=2 -instcombine -gvn -S | FileCheck %s +; The chain length is set to 2 so that this will do some vectorization; check that the order of the functions is unchanged. + +%struct.descriptor_dimension = type { i64, i64, i64 } +%struct.__st_parameter_common = type { i32, i32, i8*, i32, i32, i8*, i32* } +%struct.__st_parameter_dt = type { %struct.__st_parameter_common, i64, i64*, i64*, i8*, i8*, i32, i32, i8*, i8*, i32, i32, i8*, [256 x i8], i32*, i64, i8*, i32, i32, i8*, i8*, i32, i32, i8*, i8*, i32, i32, i8*, i8*, i32, [4 x i8] } +%"struct.array4_real(kind=4)" = type { i8*, i64, i64, [4 x %struct.descriptor_dimension] } +%"struct.array4_integer(kind=4).73" = type { i8*, i64, i64, [4 x %struct.descriptor_dimension] } +%struct.array4_unknown = type { i8*, i64, i64, [4 x %struct.descriptor_dimension] } + +@.cst4 = external unnamed_addr constant [11 x i8], align 8 +@.cst823 = external unnamed_addr constant [214 x i8], align 64 +@j.4580 = external global i32 +@j1.4581 = external global i32 +@nty1.4590 = external global [2 x i8] +@nty2.4591 = external global [2 x i8] +@xr1.4592 = external global float +@xr2.4593 = external global float +@yr1.4594 = external global float +@yr2.4595 = external global float + +@__main1_MOD_iave = external unnamed_addr global i32 +@__main1_MOD_igrp = external global i32 +@__main1_MOD_iounit = external global i32 +@__main1_MOD_ityp = external global i32 +@__main1_MOD_mclmsg = external unnamed_addr global %struct.array4_unknown, align 32 +@__main1_MOD_mxdate = external unnamed_addr global %"struct.array4_integer(kind=4).73", align 32 +@__main1_MOD_rmxval = external unnamed_addr global %"struct.array4_real(kind=4)", align 32 + +declare void @_gfortran_st_write(%struct.__st_parameter_dt*) +declare void @_gfortran_st_write_done(%struct.__st_parameter_dt*) +declare void @_gfortran_transfer_character_write(%struct.__st_parameter_dt*, i8*, i32) +declare void @_gfortran_transfer_integer_write(%struct.__st_parameter_dt*, i8*, i32) +declare void @_gfortran_transfer_real_write(%struct.__st_parameter_dt*, i8*, i32) + +define i1 @"prtmax___"(%struct.__st_parameter_dt* %memtmp3, i32 %D.4627_188.reload) nounwind { +; CHECK: prtmax__ +newFuncRoot: + br label %"" + +codeRepl80.exitStub: ; preds = %"" + ret i1 true + +"._crit_edge.exitStub": ; preds = %"" + ret i1 false + +"": ; preds = %newFuncRoot + %tmp128 = getelementptr inbounds %struct.__st_parameter_dt* %memtmp3, i32 0, i32 0 + %tmp129 = getelementptr inbounds %struct.__st_parameter_common* %tmp128, i32 0, i32 2 + store i8* getelementptr inbounds ([11 x i8]* @.cst4, i64 0, i64 0), i8** %tmp129, align 8 + %tmp130 = getelementptr inbounds %struct.__st_parameter_dt* %memtmp3, i32 0, i32 0 + %tmp131 = getelementptr inbounds %struct.__st_parameter_common* %tmp130, i32 0, i32 3 + store i32 31495, i32* %tmp131, align 4 + %tmp132 = getelementptr inbounds %struct.__st_parameter_dt* %memtmp3, i32 0, i32 5 + store i8* getelementptr inbounds ([214 x i8]* @.cst823, i64 0, i64 0), i8** %tmp132, align 8 + %tmp133 = getelementptr inbounds %struct.__st_parameter_dt* %memtmp3, i32 0, i32 6 + store i32 214, i32* %tmp133, align 4 + %tmp134 = getelementptr inbounds %struct.__st_parameter_dt* %memtmp3, i32 0, i32 0 + %tmp135 = getelementptr inbounds %struct.__st_parameter_common* %tmp134, i32 0, i32 0 + store i32 4096, i32* %tmp135, align 4 + %iounit.8748_288 = load i32* @__main1_MOD_iounit, align 4 + %tmp136 = getelementptr inbounds %struct.__st_parameter_dt* %memtmp3, i32 0, i32 0 + %tmp137 = getelementptr inbounds %struct.__st_parameter_common* %tmp136, i32 0, i32 1 + store i32 %iounit.8748_288, i32* %tmp137, align 4 + call void @_gfortran_st_write(%struct.__st_parameter_dt* %memtmp3) nounwind + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_integer_write to void (%struct.__st_parameter_dt*, i32*, i32)*)(%struct.__st_parameter_dt* %memtmp3, i32* @j.4580, i32 4) nounwind +; CHECK: @_gfortran_transfer_integer_write + %D.75807_289 = load i8** getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 0), align 8 + %j.8758_290 = load i32* @j.4580, align 4 + %D.75760_291 = sext i32 %j.8758_290 to i64 + %iave.8736_292 = load i32* @__main1_MOD_iave, align 4 + %D.75620_293 = sext i32 %iave.8736_292 to i64 + %D.75808_294 = load i64* getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 3, i64 2, i32 0), align 8 + %D.75809_295 = mul nsw i64 %D.75620_293, %D.75808_294 + %igrp.8737_296 = load i32* @__main1_MOD_igrp, align 4 + %D.75635_297 = sext i32 %igrp.8737_296 to i64 + %D.75810_298 = load i64* getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 3, i64 1, i32 0), align 8 + %D.75811_299 = mul nsw i64 %D.75635_297, %D.75810_298 + %D.75812_300 = add nsw i64 %D.75809_295, %D.75811_299 + %D.75813_301 = add nsw i64 %D.75760_291, %D.75812_300 + %ityp.8750_302 = load i32* @__main1_MOD_ityp, align 4 + %D.75704_303 = sext i32 %ityp.8750_302 to i64 + %D.75814_304 = load i64* getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 3, i64 3, i32 0), align 8 + %D.75815_305 = mul nsw i64 %D.75704_303, %D.75814_304 + %D.75816_306 = add nsw i64 %D.75813_301, %D.75815_305 + %D.75817_307 = load i64* getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 1), align 8 + %D.75818_308 = add nsw i64 %D.75816_306, %D.75817_307 + %tmp138 = bitcast i8* %D.75807_289 to [0 x float]* + %tmp139 = bitcast [0 x float]* %tmp138 to float* + %D.75819_309 = getelementptr inbounds float* %tmp139, i64 %D.75818_308 + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_real_write to void (%struct.__st_parameter_dt*, float*, i32)*)(%struct.__st_parameter_dt* %memtmp3, float* %D.75819_309, i32 4) nounwind +; CHECK: @_gfortran_transfer_real_write + %D.75820_310 = load i8** getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 0), align 8 + %j.8758_311 = load i32* @j.4580, align 4 + %D.75760_312 = sext i32 %j.8758_311 to i64 + %iave.8736_313 = load i32* @__main1_MOD_iave, align 4 + %D.75620_314 = sext i32 %iave.8736_313 to i64 + %D.75821_315 = load i64* getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 3, i64 2, i32 0), align 8 + %D.75822_316 = mul nsw i64 %D.75620_314, %D.75821_315 + %igrp.8737_317 = load i32* @__main1_MOD_igrp, align 4 + %D.75635_318 = sext i32 %igrp.8737_317 to i64 + %D.75823_319 = load i64* getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 3, i64 1, i32 0), align 8 + %D.75824_320 = mul nsw i64 %D.75635_318, %D.75823_319 + %D.75825_321 = add nsw i64 %D.75822_316, %D.75824_320 + %D.75826_322 = add nsw i64 %D.75760_312, %D.75825_321 + %ityp.8750_323 = load i32* @__main1_MOD_ityp, align 4 + %D.75704_324 = sext i32 %ityp.8750_323 to i64 + %D.75827_325 = load i64* getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 3, i64 3, i32 0), align 8 + %D.75828_326 = mul nsw i64 %D.75704_324, %D.75827_325 + %D.75829_327 = add nsw i64 %D.75826_322, %D.75828_326 + %D.75830_328 = load i64* getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 1), align 8 + %D.75831_329 = add nsw i64 %D.75829_327, %D.75830_328 + %tmp140 = bitcast i8* %D.75820_310 to [0 x [1 x i8]]* + %tmp141 = bitcast [0 x [1 x i8]]* %tmp140 to [1 x i8]* + %D.75832_330 = getelementptr inbounds [1 x i8]* %tmp141, i64 %D.75831_329 + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_character_write to void (%struct.__st_parameter_dt*, [1 x i8]*, i32)*)(%struct.__st_parameter_dt* %memtmp3, [1 x i8]* %D.75832_330, i32 1) nounwind +; CHECK: @_gfortran_transfer_character_write + %D.75833_331 = load i8** getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 0), align 8 + %j.8758_332 = load i32* @j.4580, align 4 + %D.75760_333 = sext i32 %j.8758_332 to i64 + %iave.8736_334 = load i32* @__main1_MOD_iave, align 4 + %D.75620_335 = sext i32 %iave.8736_334 to i64 + %D.75834_336 = load i64* getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 3, i64 2, i32 0), align 8 + %D.75835_337 = mul nsw i64 %D.75620_335, %D.75834_336 + %igrp.8737_338 = load i32* @__main1_MOD_igrp, align 4 + %D.75635_339 = sext i32 %igrp.8737_338 to i64 + %D.75836_340 = load i64* getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 3, i64 1, i32 0), align 8 + %D.75837_341 = mul nsw i64 %D.75635_339, %D.75836_340 + %D.75838_342 = add nsw i64 %D.75835_337, %D.75837_341 + %D.75839_343 = add nsw i64 %D.75760_333, %D.75838_342 + %ityp.8750_344 = load i32* @__main1_MOD_ityp, align 4 + %D.75704_345 = sext i32 %ityp.8750_344 to i64 + %D.75840_346 = load i64* getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 3, i64 3, i32 0), align 8 + %D.75841_347 = mul nsw i64 %D.75704_345, %D.75840_346 + %D.75842_348 = add nsw i64 %D.75839_343, %D.75841_347 + %D.75843_349 = load i64* getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 1), align 8 + %D.75844_350 = add nsw i64 %D.75842_348, %D.75843_349 + %tmp142 = bitcast i8* %D.75833_331 to [0 x i32]* + %tmp143 = bitcast [0 x i32]* %tmp142 to i32* + %D.75845_351 = getelementptr inbounds i32* %tmp143, i64 %D.75844_350 + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_integer_write to void (%struct.__st_parameter_dt*, i32*, i32)*)(%struct.__st_parameter_dt* %memtmp3, i32* %D.75845_351, i32 4) nounwind +; CHECK: @_gfortran_transfer_integer_write + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_real_write to void (%struct.__st_parameter_dt*, float*, i32)*)(%struct.__st_parameter_dt* %memtmp3, float* @xr1.4592, i32 4) nounwind +; CHECK: @_gfortran_transfer_real_write + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_real_write to void (%struct.__st_parameter_dt*, float*, i32)*)(%struct.__st_parameter_dt* %memtmp3, float* @yr1.4594, i32 4) nounwind +; CHECK: @_gfortran_transfer_real_write + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_character_write to void (%struct.__st_parameter_dt*, [2 x i8]*, i32)*)(%struct.__st_parameter_dt* %memtmp3, [2 x i8]* @nty1.4590, i32 2) nounwind +; CHECK: @_gfortran_transfer_character_write + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_integer_write to void (%struct.__st_parameter_dt*, i32*, i32)*)(%struct.__st_parameter_dt* %memtmp3, i32* @j1.4581, i32 4) nounwind +; CHECK: @_gfortran_transfer_integer_write + %D.75807_352 = load i8** getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 0), align 8 + %j1.8760_353 = load i32* @j1.4581, align 4 + %D.75773_354 = sext i32 %j1.8760_353 to i64 + %iave.8736_355 = load i32* @__main1_MOD_iave, align 4 + %D.75620_356 = sext i32 %iave.8736_355 to i64 + %D.75808_357 = load i64* getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 3, i64 2, i32 0), align 8 + %D.75809_358 = mul nsw i64 %D.75620_356, %D.75808_357 + %igrp.8737_359 = load i32* @__main1_MOD_igrp, align 4 + %D.75635_360 = sext i32 %igrp.8737_359 to i64 + %D.75810_361 = load i64* getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 3, i64 1, i32 0), align 8 + %D.75811_362 = mul nsw i64 %D.75635_360, %D.75810_361 + %D.75812_363 = add nsw i64 %D.75809_358, %D.75811_362 + %D.75846_364 = add nsw i64 %D.75773_354, %D.75812_363 + %ityp.8750_365 = load i32* @__main1_MOD_ityp, align 4 + %D.75704_366 = sext i32 %ityp.8750_365 to i64 + %D.75814_367 = load i64* getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 3, i64 3, i32 0), align 8 + %D.75815_368 = mul nsw i64 %D.75704_366, %D.75814_367 + %D.75847_369 = add nsw i64 %D.75846_364, %D.75815_368 + %D.75817_370 = load i64* getelementptr inbounds (%"struct.array4_real(kind=4)"* @__main1_MOD_rmxval, i64 0, i32 1), align 8 + %D.75848_371 = add nsw i64 %D.75847_369, %D.75817_370 + %tmp144 = bitcast i8* %D.75807_352 to [0 x float]* + %tmp145 = bitcast [0 x float]* %tmp144 to float* + %D.75849_372 = getelementptr inbounds float* %tmp145, i64 %D.75848_371 + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_real_write to void (%struct.__st_parameter_dt*, float*, i32)*)(%struct.__st_parameter_dt* %memtmp3, float* %D.75849_372, i32 4) nounwind +; CHECK: @_gfortran_transfer_real_write + %D.75820_373 = load i8** getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 0), align 8 + %j1.8760_374 = load i32* @j1.4581, align 4 + %D.75773_375 = sext i32 %j1.8760_374 to i64 + %iave.8736_376 = load i32* @__main1_MOD_iave, align 4 + %D.75620_377 = sext i32 %iave.8736_376 to i64 + %D.75821_378 = load i64* getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 3, i64 2, i32 0), align 8 + %D.75822_379 = mul nsw i64 %D.75620_377, %D.75821_378 + %igrp.8737_380 = load i32* @__main1_MOD_igrp, align 4 + %D.75635_381 = sext i32 %igrp.8737_380 to i64 + %D.75823_382 = load i64* getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 3, i64 1, i32 0), align 8 + %D.75824_383 = mul nsw i64 %D.75635_381, %D.75823_382 + %D.75825_384 = add nsw i64 %D.75822_379, %D.75824_383 + %D.75850_385 = add nsw i64 %D.75773_375, %D.75825_384 + %ityp.8750_386 = load i32* @__main1_MOD_ityp, align 4 + %D.75704_387 = sext i32 %ityp.8750_386 to i64 + %D.75827_388 = load i64* getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 3, i64 3, i32 0), align 8 + %D.75828_389 = mul nsw i64 %D.75704_387, %D.75827_388 + %D.75851_390 = add nsw i64 %D.75850_385, %D.75828_389 + %D.75830_391 = load i64* getelementptr inbounds (%struct.array4_unknown* @__main1_MOD_mclmsg, i64 0, i32 1), align 8 + %D.75852_392 = add nsw i64 %D.75851_390, %D.75830_391 + %tmp146 = bitcast i8* %D.75820_373 to [0 x [1 x i8]]* + %tmp147 = bitcast [0 x [1 x i8]]* %tmp146 to [1 x i8]* + %D.75853_393 = getelementptr inbounds [1 x i8]* %tmp147, i64 %D.75852_392 + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_character_write to void (%struct.__st_parameter_dt*, [1 x i8]*, i32)*)(%struct.__st_parameter_dt* %memtmp3, [1 x i8]* %D.75853_393, i32 1) nounwind +; CHECK: @_gfortran_transfer_character_write + %D.75833_394 = load i8** getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 0), align 8 + %j1.8760_395 = load i32* @j1.4581, align 4 + %D.75773_396 = sext i32 %j1.8760_395 to i64 + %iave.8736_397 = load i32* @__main1_MOD_iave, align 4 + %D.75620_398 = sext i32 %iave.8736_397 to i64 + %D.75834_399 = load i64* getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 3, i64 2, i32 0), align 8 + %D.75835_400 = mul nsw i64 %D.75620_398, %D.75834_399 + %igrp.8737_401 = load i32* @__main1_MOD_igrp, align 4 + %D.75635_402 = sext i32 %igrp.8737_401 to i64 + %D.75836_403 = load i64* getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 3, i64 1, i32 0), align 8 + %D.75837_404 = mul nsw i64 %D.75635_402, %D.75836_403 + %D.75838_405 = add nsw i64 %D.75835_400, %D.75837_404 + %D.75854_406 = add nsw i64 %D.75773_396, %D.75838_405 + %ityp.8750_407 = load i32* @__main1_MOD_ityp, align 4 + %D.75704_408 = sext i32 %ityp.8750_407 to i64 + %D.75840_409 = load i64* getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 3, i64 3, i32 0), align 8 + %D.75841_410 = mul nsw i64 %D.75704_408, %D.75840_409 + %D.75855_411 = add nsw i64 %D.75854_406, %D.75841_410 + %D.75843_412 = load i64* getelementptr inbounds (%"struct.array4_integer(kind=4).73"* @__main1_MOD_mxdate, i64 0, i32 1), align 8 + %D.75856_413 = add nsw i64 %D.75855_411, %D.75843_412 + %tmp148 = bitcast i8* %D.75833_394 to [0 x i32]* + %tmp149 = bitcast [0 x i32]* %tmp148 to i32* + %D.75857_414 = getelementptr inbounds i32* %tmp149, i64 %D.75856_413 + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_integer_write to void (%struct.__st_parameter_dt*, i32*, i32)*)(%struct.__st_parameter_dt* %memtmp3, i32* %D.75857_414, i32 4) nounwind +; CHECK: @_gfortran_transfer_integer_write + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_real_write to void (%struct.__st_parameter_dt*, float*, i32)*)(%struct.__st_parameter_dt* %memtmp3, float* @xr2.4593, i32 4) nounwind +; CHECK: @_gfortran_transfer_real_write + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_real_write to void (%struct.__st_parameter_dt*, float*, i32)*)(%struct.__st_parameter_dt* %memtmp3, float* @yr2.4595, i32 4) nounwind +; CHECK: @_gfortran_transfer_real_write + call void bitcast (void (%struct.__st_parameter_dt*, i8*, i32)* @_gfortran_transfer_character_write to void (%struct.__st_parameter_dt*, [2 x i8]*, i32)*)(%struct.__st_parameter_dt* %memtmp3, [2 x i8]* @nty2.4591, i32 2) nounwind +; CHECK: @_gfortran_transfer_character_write + call void @_gfortran_st_write_done(%struct.__st_parameter_dt* %memtmp3) nounwind +; CHECK: @_gfortran_st_write_done + %j.8758_415 = load i32* @j.4580, align 4 + %D.4634_416 = icmp eq i32 %j.8758_415, %D.4627_188.reload + %j.8758_417 = load i32* @j.4580, align 4 + %j.8770_418 = add nsw i32 %j.8758_417, 1 + store i32 %j.8770_418, i32* @j.4580, align 4 + %tmp150 = icmp ne i1 %D.4634_416, false + br i1 %tmp150, label %codeRepl80.exitStub, label %"._crit_edge.exitStub" +} + diff --git a/test/Transforms/BBVectorize/ld1.ll b/test/Transforms/BBVectorize/ld1.ll new file mode 100644 index 000000000000..cea225d076e1 --- /dev/null +++ b/test/Transforms/BBVectorize/ld1.ll @@ -0,0 +1,41 @@ +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" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s + +define double @test1(double* %a, double* %b, double* %c) nounwind uwtable readonly { +entry: + %i0 = load double* %a, align 8 + %i1 = load double* %b, align 8 + %mul = fmul double %i0, %i1 + %i2 = load double* %c, align 8 + %add = fadd double %mul, %i2 + %arrayidx3 = getelementptr inbounds double* %a, i64 1 + %i3 = load double* %arrayidx3, align 8 + %arrayidx4 = getelementptr inbounds double* %b, i64 1 + %i4 = load double* %arrayidx4, align 8 + %mul5 = fmul double %i3, %i4 + %arrayidx6 = getelementptr inbounds double* %c, i64 1 + %i5 = load double* %arrayidx6, align 8 + %add7 = fadd double %mul5, %i5 + %mul9 = fmul double %add, %i1 + %add11 = fadd double %mul9, %i2 + %mul13 = fmul double %add7, %i4 + %add15 = fadd double %mul13, %i5 + %mul16 = fmul double %add11, %add15 + ret double %mul16 +; CHECK: @test1 +; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>* +; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>* +; CHECK: %i2.v.i0 = bitcast double* %c to <2 x double>* +; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8 +; CHECK: %i1 = load <2 x double>* %i1.v.i0, align 8 +; CHECK: %mul = fmul <2 x double> %i0, %i1 +; CHECK: %i2 = load <2 x double>* %i2.v.i0, align 8 +; CHECK: %add = fadd <2 x double> %mul, %i2 +; CHECK: %mul9 = fmul <2 x double> %add, %i1 +; CHECK: %add11 = fadd <2 x double> %mul9, %i2 +; CHECK: %add11.v.r1 = extractelement <2 x double> %add11, i32 0 +; CHECK: %add11.v.r2 = extractelement <2 x double> %add11, i32 1 +; CHECK: %mul16 = fmul double %add11.v.r1, %add11.v.r2 +; CHECK: ret double %mul16 +} + diff --git a/test/Transforms/BBVectorize/lit.local.cfg b/test/Transforms/BBVectorize/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/BBVectorize/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/BBVectorize/loop1.ll b/test/Transforms/BBVectorize/loop1.ll new file mode 100644 index 000000000000..bebc91ad91a0 --- /dev/null +++ b/test/Transforms/BBVectorize/loop1.ll @@ -0,0 +1,93 @@ +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" +target triple = "x86_64-unknown-linux-gnu" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s +; RUN: opt < %s -basicaa -loop-unroll -unroll-threshold=45 -unroll-allow-partial -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-UNRL +; The second check covers the use of alias analysis (with loop unrolling). + +define void @test1(double* noalias %out, double* noalias %in1, double* noalias %in2) nounwind uwtable { +entry: + br label %for.body +; CHECK: @test1 +; CHECK-UNRL: @test1 + +for.body: ; preds = %for.body, %entry + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %arrayidx = getelementptr inbounds double* %in1, i64 %indvars.iv + %0 = load double* %arrayidx, align 8 + %arrayidx2 = getelementptr inbounds double* %in2, i64 %indvars.iv + %1 = load double* %arrayidx2, align 8 + %mul = fmul double %0, %0 + %mul3 = fmul double %0, %1 + %add = fadd double %mul, %mul3 + %add4 = fadd double %1, %1 + %add5 = fadd double %add4, %0 + %mul6 = fmul double %0, %add5 + %add7 = fadd double %add, %mul6 + %mul8 = fmul double %1, %1 + %add9 = fadd double %0, %0 + %add10 = fadd double %add9, %0 + %mul11 = fmul double %mul8, %add10 + %add12 = fadd double %add7, %mul11 + %arrayidx14 = getelementptr inbounds double* %out, i64 %indvars.iv + store double %add12, double* %arrayidx14, align 8 + %indvars.iv.next = add i64 %indvars.iv, 1 + %lftr.wideiv = trunc i64 %indvars.iv.next to i32 + %exitcond = icmp eq i32 %lftr.wideiv, 10 + br i1 %exitcond, label %for.end, label %for.body +; CHECK: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] +; CHECK: %arrayidx = getelementptr inbounds double* %in1, i64 %indvars.iv +; CHECK: %0 = load double* %arrayidx, align 8 +; CHECK: %arrayidx2 = getelementptr inbounds double* %in2, i64 %indvars.iv +; CHECK: %1 = load double* %arrayidx2, align 8 +; CHECK: %mul = fmul double %0, %0 +; CHECK: %mul3 = fmul double %0, %1 +; CHECK: %add = fadd double %mul, %mul3 +; CHECK: %add4.v.i1.1 = insertelement <2 x double> undef, double %1, i32 0 +; CHECK: %mul8 = fmul double %1, %1 +; CHECK: %add4.v.i1.2 = insertelement <2 x double> %add4.v.i1.1, double %0, i32 1 +; CHECK: %add4 = fadd <2 x double> %add4.v.i1.2, %add4.v.i1.2 +; CHECK: %add5.v.i1.1 = insertelement <2 x double> undef, double %0, i32 0 +; CHECK: %add5.v.i1.2 = insertelement <2 x double> %add5.v.i1.1, double %0, i32 1 +; CHECK: %add5 = fadd <2 x double> %add4, %add5.v.i1.2 +; CHECK: %mul6.v.i0.2 = insertelement <2 x double> %add5.v.i1.1, double %mul8, i32 1 +; CHECK: %mul6 = fmul <2 x double> %mul6.v.i0.2, %add5 +; CHECK: %mul6.v.r1 = extractelement <2 x double> %mul6, i32 0 +; CHECK: %mul6.v.r2 = extractelement <2 x double> %mul6, i32 1 +; CHECK: %add7 = fadd double %add, %mul6.v.r1 +; CHECK: %add12 = fadd double %add7, %mul6.v.r2 +; CHECK: %arrayidx14 = getelementptr inbounds double* %out, i64 %indvars.iv +; CHECK: store double %add12, double* %arrayidx14, align 8 +; CHECK: %indvars.iv.next = add i64 %indvars.iv, 1 +; CHECK: %lftr.wideiv = trunc i64 %indvars.iv.next to i32 +; CHECK: %exitcond = icmp eq i32 %lftr.wideiv, 10 +; CHECK: br i1 %exitcond, label %for.end, label %for.body +; CHECK-UNRL: %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next.1, %for.body ] +; CHECK-UNRL: %arrayidx = getelementptr inbounds double* %in1, i64 %indvars.iv +; CHECK-UNRL: %0 = bitcast double* %arrayidx to <2 x double>* +; CHECK-UNRL: %arrayidx2 = getelementptr inbounds double* %in2, i64 %indvars.iv +; CHECK-UNRL: %1 = bitcast double* %arrayidx2 to <2 x double>* +; CHECK-UNRL: %arrayidx14 = getelementptr inbounds double* %out, i64 %indvars.iv +; CHECK-UNRL: %2 = load <2 x double>* %0, align 8 +; CHECK-UNRL: %3 = load <2 x double>* %1, align 8 +; CHECK-UNRL: %mul = fmul <2 x double> %2, %2 +; CHECK-UNRL: %mul3 = fmul <2 x double> %2, %3 +; CHECK-UNRL: %add = fadd <2 x double> %mul, %mul3 +; CHECK-UNRL: %add4 = fadd <2 x double> %3, %3 +; CHECK-UNRL: %add5 = fadd <2 x double> %add4, %2 +; CHECK-UNRL: %mul6 = fmul <2 x double> %2, %add5 +; CHECK-UNRL: %add7 = fadd <2 x double> %add, %mul6 +; CHECK-UNRL: %mul8 = fmul <2 x double> %3, %3 +; CHECK-UNRL: %add9 = fadd <2 x double> %2, %2 +; CHECK-UNRL: %add10 = fadd <2 x double> %add9, %2 +; CHECK-UNRL: %mul11 = fmul <2 x double> %mul8, %add10 +; CHECK-UNRL: %add12 = fadd <2 x double> %add7, %mul11 +; CHECK-UNRL: %4 = bitcast double* %arrayidx14 to <2 x double>* +; CHECK-UNRL: store <2 x double> %add12, <2 x double>* %4, align 8 +; CHECK-UNRL: %indvars.iv.next.1 = add i64 %indvars.iv, 2 +; CHECK-UNRL: %lftr.wideiv.1 = trunc i64 %indvars.iv.next.1 to i32 +; CHECK-UNRL: %exitcond.1 = icmp eq i32 %lftr.wideiv.1, 10 +; CHECK-UNRL: br i1 %exitcond.1, label %for.end, label %for.body + +for.end: ; preds = %for.body + ret void +} diff --git a/test/Transforms/BBVectorize/mem-op-depth.ll b/test/Transforms/BBVectorize/mem-op-depth.ll new file mode 100644 index 000000000000..84f16bd2f47d --- /dev/null +++ b/test/Transforms/BBVectorize/mem-op-depth.ll @@ -0,0 +1,22 @@ +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" +target triple = "x86_64-unknown-linux-gnu" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=6 -instcombine -gvn -S | FileCheck %s + +@A = common global [1024 x float] zeroinitializer, align 16 +@B = common global [1024 x float] zeroinitializer, align 16 + +define i32 @test1() nounwind { +; CHECK: @test1 + %V1 = load float* getelementptr inbounds ([1024 x float]* @A, i64 0, i64 0), align 16 + %V2 = load float* getelementptr inbounds ([1024 x float]* @A, i64 0, i64 1), align 4 + %V3= load float* getelementptr inbounds ([1024 x float]* @A, i64 0, i64 2), align 8 + %V4 = load float* getelementptr inbounds ([1024 x float]* @A, i64 0, i64 3), align 4 +; CHECK: %V1 = load <4 x float>* bitcast ([1024 x float]* @A to <4 x float>*), align 16 + store float %V1, float* getelementptr inbounds ([1024 x float]* @B, i64 0, i64 0), align 16 + store float %V2, float* getelementptr inbounds ([1024 x float]* @B, i64 0, i64 1), align 4 + store float %V3, float* getelementptr inbounds ([1024 x float]* @B, i64 0, i64 2), align 8 + store float %V4, float* getelementptr inbounds ([1024 x float]* @B, i64 0, i64 3), align 4 +; CHECK-NEXT: store <4 x float> %V1, <4 x float>* bitcast ([1024 x float]* @B to <4 x float>*), align 16 + ret i32 0 +; CHECK-NEXT: ret i32 0 +} diff --git a/test/Transforms/BBVectorize/req-depth.ll b/test/Transforms/BBVectorize/req-depth.ll new file mode 100644 index 000000000000..8c9cc3c188e3 --- /dev/null +++ b/test/Transforms/BBVectorize/req-depth.ll @@ -0,0 +1,17 @@ +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" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth 3 -S | FileCheck %s -check-prefix=CHECK-RD3 +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth 2 -S | FileCheck %s -check-prefix=CHECK-RD2 + +define double @test1(double %A1, double %A2, double %B1, double %B2) { + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 + %Y1 = fmul double %X1, %A1 + %Y2 = fmul double %X2, %A2 + %R = fmul double %Y1, %Y2 + ret double %R +; CHECK-RD3: @test1 +; CHECK-RD2: @test1 +; CHECK-RD3-NOT: <2 x double> +; CHECK-RD2: <2 x double> +} + diff --git a/test/Transforms/BBVectorize/search-limit.ll b/test/Transforms/BBVectorize/search-limit.ll new file mode 100644 index 000000000000..d9945b563077 --- /dev/null +++ b/test/Transforms/BBVectorize/search-limit.ll @@ -0,0 +1,46 @@ +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" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-search-limit=4 -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-SL4 + +define double @test1(double %A1, double %A2, double %B1, double %B2) { +; CHECK: @test1 +; CHECK-SL4: @test1 +; CHECK-SL4-NOT: <2 x double> +; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1 +; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1 + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 +; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2 + %Y1 = fmul double %X1, %A1 + %Y2 = fmul double %X2, %A2 +; CHECK: %Y1 = fmul <2 x double> %X1, %X1.v.i0.2 + %Z1 = fadd double %Y1, %B1 + ; Here we have a dependency chain: the short search limit will not + ; see past this chain and so will not see the second part of the + ; pair to vectorize. + %mul41 = fmul double %Z1, %Y2 + %sub48 = fsub double %Z1, %mul41 + %mul62 = fmul double %Z1, %sub48 + %sub69 = fsub double %Z1, %mul62 + %mul83 = fmul double %Z1, %sub69 + %sub90 = fsub double %Z1, %mul83 + %mul104 = fmul double %Z1, %sub90 + %sub111 = fsub double %Z1, %mul104 + %mul125 = fmul double %Z1, %sub111 + %sub132 = fsub double %Z1, %mul125 + %mul146 = fmul double %Z1, %sub132 + %sub153 = fsub double %Z1, %mul146 + ; end of chain. + %Z2 = fadd double %Y2, %B2 +; CHECK: %Z1 = fadd <2 x double> %Y1, %X1.v.i1.2 + %R1 = fdiv double %Z1, %Z2 + %R = fmul double %R1, %sub153 +; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1 +; CHECK: %R1 = fdiv double %Z1.v.r1, %Z1.v.r2 + ret double %R +; CHECK: ret double %R +} + diff --git a/test/Transforms/BBVectorize/simple-int.ll b/test/Transforms/BBVectorize/simple-int.ll new file mode 100644 index 000000000000..68449771436e --- /dev/null +++ b/test/Transforms/BBVectorize/simple-int.ll @@ -0,0 +1,103 @@ +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" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s + +declare double @llvm.fma.f64(double, double, double) +declare double @llvm.cos.f64(double) +declare double @llvm.powi.f64(double, i32) + +; Basic depth-3 chain with fma +define double @test1(double %A1, double %A2, double %B1, double %B2, double %C1, double %C2) { + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 + %Y1 = call double @llvm.fma.f64(double %X1, double %A1, double %C1) + %Y2 = call double @llvm.fma.f64(double %X2, double %A2, double %C2) + %Z1 = fadd double %Y1, %B1 + %Z2 = fadd double %Y2, %B2 + %R = fmul double %Z1, %Z2 + ret double %R +; CHECK: @test1 +; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1 +; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1 +; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2 +; CHECK: %Y1.v.i2.1 = insertelement <2 x double> undef, double %C1, i32 0 +; CHECK: %Y1.v.i2.2 = insertelement <2 x double> %Y1.v.i2.1, double %C2, i32 1 +; CHECK: %Y1 = call <2 x double> @llvm.fma.v2f64(<2 x double> %X1, <2 x double> %X1.v.i0.2, <2 x double> %Y1.v.i2.2) +; CHECK: %Z1 = fadd <2 x double> %Y1, %X1.v.i1.2 +; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1 +; CHECK: %R = fmul double %Z1.v.r1, %Z1.v.r2 +; CHECK: ret double %R +} + +; Basic depth-3 chain with cos +define double @test2(double %A1, double %A2, double %B1, double %B2) { + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 + %Y1 = call double @llvm.cos.f64(double %X1) + %Y2 = call double @llvm.cos.f64(double %X2) + %Z1 = fadd double %Y1, %B1 + %Z2 = fadd double %Y2, %B2 + %R = fmul double %Z1, %Z2 + ret double %R +; CHECK: @test2 +; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1 +; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1 +; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2 +; CHECK: %Y1 = call <2 x double> @llvm.cos.v2f64(<2 x double> %X1) +; CHECK: %Z1 = fadd <2 x double> %Y1, %X1.v.i1.2 +; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1 +; CHECK: %R = fmul double %Z1.v.r1, %Z1.v.r2 +; CHECK: ret double %R +} + +; Basic depth-3 chain with powi +define double @test3(double %A1, double %A2, double %B1, double %B2, i32 %P) { + + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 + %Y1 = call double @llvm.powi.f64(double %X1, i32 %P) + %Y2 = call double @llvm.powi.f64(double %X2, i32 %P) + %Z1 = fadd double %Y1, %B1 + %Z2 = fadd double %Y2, %B2 + %R = fmul double %Z1, %Z2 + ret double %R +; CHECK: @test3 +; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1 +; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1 +; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2 +; CHECK: %Y1 = call <2 x double> @llvm.powi.v2f64(<2 x double> %X1, i32 %P) +; CHECK: %Z1 = fadd <2 x double> %Y1, %X1.v.i1.2 +; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1 +; CHECK: %R = fmul double %Z1.v.r1, %Z1.v.r2 +; CHECK: ret double %R +} + +; Basic depth-3 chain with powi (different powers: should not vectorize) +define double @test4(double %A1, double %A2, double %B1, double %B2, i32 %P) { + + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 + %P2 = add i32 %P, 1 + %Y1 = call double @llvm.powi.f64(double %X1, i32 %P) + %Y2 = call double @llvm.powi.f64(double %X2, i32 %P2) + %Z1 = fadd double %Y1, %B1 + %Z2 = fadd double %Y2, %B2 + %R = fmul double %Z1, %Z2 + ret double %R +; CHECK: @test4 +; CHECK-NOT: <2 x double> +; CHECK: ret double %R +} + +; CHECK: declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>) nounwind readnone +; CHECK: declare <2 x double> @llvm.cos.v2f64(<2 x double>) nounwind readonly +; CHECK: declare <2 x double> @llvm.powi.v2f64(<2 x double>, i32) nounwind readonly + diff --git a/test/Transforms/BBVectorize/simple-ldstr.ll b/test/Transforms/BBVectorize/simple-ldstr.ll new file mode 100644 index 000000000000..a5397eeb1f96 --- /dev/null +++ b/test/Transforms/BBVectorize/simple-ldstr.ll @@ -0,0 +1,110 @@ +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" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-aligned-only -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-AO + +; Simple 3-pair chain with loads and stores +define void @test1(double* %a, double* %b, double* %c) nounwind uwtable readonly { +entry: + %i0 = load double* %a, align 8 + %i1 = load double* %b, align 8 + %mul = fmul double %i0, %i1 + %arrayidx3 = getelementptr inbounds double* %a, i64 1 + %i3 = load double* %arrayidx3, align 8 + %arrayidx4 = getelementptr inbounds double* %b, i64 1 + %i4 = load double* %arrayidx4, align 8 + %mul5 = fmul double %i3, %i4 + store double %mul, double* %c, align 8 + %arrayidx5 = getelementptr inbounds double* %c, i64 1 + store double %mul5, double* %arrayidx5, align 8 + ret void +; CHECK: @test1 +; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>* +; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>* +; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8 +; CHECK: %i1 = load <2 x double>* %i1.v.i0, align 8 +; CHECK: %mul = fmul <2 x double> %i0, %i1 +; CHECK: %0 = bitcast double* %c to <2 x double>* +; CHECK: store <2 x double> %mul, <2 x double>* %0, align 8 +; CHECK: ret void +; CHECK-AO: @test1 +; CHECK-AO-NOT: <2 x double> +} + +; Simple chain with extending loads and stores +define void @test2(float* %a, float* %b, double* %c) nounwind uwtable readonly { +entry: + %i0f = load float* %a, align 4 + %i0 = fpext float %i0f to double + %i1f = load float* %b, align 4 + %i1 = fpext float %i1f to double + %mul = fmul double %i0, %i1 + %arrayidx3 = getelementptr inbounds float* %a, i64 1 + %i3f = load float* %arrayidx3, align 4 + %i3 = fpext float %i3f to double + %arrayidx4 = getelementptr inbounds float* %b, i64 1 + %i4f = load float* %arrayidx4, align 4 + %i4 = fpext float %i4f to double + %mul5 = fmul double %i3, %i4 + store double %mul, double* %c, align 8 + %arrayidx5 = getelementptr inbounds double* %c, i64 1 + store double %mul5, double* %arrayidx5, align 8 + ret void +; CHECK: @test2 +; CHECK: %i0f.v.i0 = bitcast float* %a to <2 x float>* +; CHECK: %i1f.v.i0 = bitcast float* %b to <2 x float>* +; CHECK: %i0f = load <2 x float>* %i0f.v.i0, align 4 +; CHECK: %i0 = fpext <2 x float> %i0f to <2 x double> +; CHECK: %i1f = load <2 x float>* %i1f.v.i0, align 4 +; CHECK: %i1 = fpext <2 x float> %i1f to <2 x double> +; CHECK: %mul = fmul <2 x double> %i0, %i1 +; CHECK: %0 = bitcast double* %c to <2 x double>* +; CHECK: store <2 x double> %mul, <2 x double>* %0, align 8 +; CHECK: ret void +; CHECK-AO: @test2 +; CHECK-AO-NOT: <2 x double> +} + +; Simple chain with loads and truncating stores +define void @test3(double* %a, double* %b, float* %c) nounwind uwtable readonly { +entry: + %i0 = load double* %a, align 8 + %i1 = load double* %b, align 8 + %mul = fmul double %i0, %i1 + %mulf = fptrunc double %mul to float + %arrayidx3 = getelementptr inbounds double* %a, i64 1 + %i3 = load double* %arrayidx3, align 8 + %arrayidx4 = getelementptr inbounds double* %b, i64 1 + %i4 = load double* %arrayidx4, align 8 + %mul5 = fmul double %i3, %i4 + %mul5f = fptrunc double %mul5 to float + store float %mulf, float* %c, align 8 + %arrayidx5 = getelementptr inbounds float* %c, i64 1 + store float %mul5f, float* %arrayidx5, align 4 + ret void +; CHECK: @test3 +; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>* +; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>* +; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8 +; CHECK: %i1 = load <2 x double>* %i1.v.i0, align 8 +; CHECK: %mul = fmul <2 x double> %i0, %i1 +; CHECK: %mulf = fptrunc <2 x double> %mul to <2 x float> +; CHECK: %0 = bitcast float* %c to <2 x float>* +; CHECK: store <2 x float> %mulf, <2 x float>* %0, align 8 +; CHECK: ret void +; CHECK-AO: @test3 +; CHECK-AO: %i0 = load double* %a, align 8 +; CHECK-AO: %i1 = load double* %b, align 8 +; CHECK-AO: %mul.v.i1.1 = insertelement <2 x double> undef, double %i1, i32 0 +; CHECK-AO: %mul.v.i0.1 = insertelement <2 x double> undef, double %i0, i32 0 +; CHECK-AO: %arrayidx3 = getelementptr inbounds double* %a, i64 1 +; CHECK-AO: %i3 = load double* %arrayidx3, align 8 +; CHECK-AO: %arrayidx4 = getelementptr inbounds double* %b, i64 1 +; CHECK-AO: %i4 = load double* %arrayidx4, align 8 +; CHECK-AO: %mul.v.i1.2 = insertelement <2 x double> %mul.v.i1.1, double %i4, i32 1 +; CHECK-AO: %mul.v.i0.2 = insertelement <2 x double> %mul.v.i0.1, double %i3, i32 1 +; CHECK-AO: %mul = fmul <2 x double> %mul.v.i0.2, %mul.v.i1.2 +; CHECK-AO: %mulf = fptrunc <2 x double> %mul to <2 x float> +; CHECK-AO: %0 = bitcast float* %c to <2 x float>* +; CHECK-AO: store <2 x float> %mulf, <2 x float>* %0, align 8 +; CHECK-AO: ret void +} diff --git a/test/Transforms/BBVectorize/simple.ll b/test/Transforms/BBVectorize/simple.ll new file mode 100644 index 000000000000..904d766bb673 --- /dev/null +++ b/test/Transforms/BBVectorize/simple.ll @@ -0,0 +1,152 @@ +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" +; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -instcombine -gvn -S | FileCheck %s + +; Basic depth-3 chain +define double @test1(double %A1, double %A2, double %B1, double %B2) { +; CHECK: @test1 +; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1 +; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1 + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 +; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2 + %Y1 = fmul double %X1, %A1 + %Y2 = fmul double %X2, %A2 +; CHECK: %Y1 = fmul <2 x double> %X1, %X1.v.i0.2 + %Z1 = fadd double %Y1, %B1 + %Z2 = fadd double %Y2, %B2 +; CHECK: %Z1 = fadd <2 x double> %Y1, %X1.v.i1.2 + %R = fmul double %Z1, %Z2 +; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1 +; CHECK: %R = fmul double %Z1.v.r1, %Z1.v.r2 + ret double %R +; CHECK: ret double %R +} + +; Basic depth-3 chain (last pair permuted) +define double @test2(double %A1, double %A2, double %B1, double %B2) { +; CHECK: @test2 +; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1 +; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1 + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 +; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2 + %Y1 = fmul double %X1, %A1 + %Y2 = fmul double %X2, %A2 +; CHECK: %Y1 = fmul <2 x double> %X1, %X1.v.i0.2 + %Z1 = fadd double %Y2, %B1 + %Z2 = fadd double %Y1, %B2 +; CHECK: %Z1.v.i0 = shufflevector <2 x double> %Y1, <2 x double> undef, <2 x i32> +; CHECK: %Z1 = fadd <2 x double> %Z1.v.i0, %X1.v.i1.2 + %R = fmul double %Z1, %Z2 +; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1 +; CHECK: %R = fmul double %Z1.v.r1, %Z1.v.r2 + ret double %R +; CHECK: ret double %R +} + +; Basic depth-3 chain (last pair first splat) +define double @test3(double %A1, double %A2, double %B1, double %B2) { +; CHECK: @test3 +; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1 +; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1 + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 +; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2 + %Y1 = fmul double %X1, %A1 + %Y2 = fmul double %X2, %A2 +; CHECK: %Y1 = fmul <2 x double> %X1, %X1.v.i0.2 + %Z1 = fadd double %Y2, %B1 + %Z2 = fadd double %Y2, %B2 +; CHECK: %Z1.v.i0 = shufflevector <2 x double> %Y1, <2 x double> undef, <2 x i32> +; CHECK: %Z1 = fadd <2 x double> %Z1.v.i0, %X1.v.i1.2 + %R = fmul double %Z1, %Z2 +; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1 +; CHECK: %R = fmul double %Z1.v.r1, %Z1.v.r2 + ret double %R +; CHECK: ret double %R +} + +; Basic depth-3 chain (last pair second splat) +define double @test4(double %A1, double %A2, double %B1, double %B2) { +; CHECK: @test4 +; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0 +; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0 +; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1 +; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1 + %X1 = fsub double %A1, %B1 + %X2 = fsub double %A2, %B2 +; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2 + %Y1 = fmul double %X1, %A1 + %Y2 = fmul double %X2, %A2 +; CHECK: %Y1 = fmul <2 x double> %X1, %X1.v.i0.2 + %Z1 = fadd double %Y1, %B1 + %Z2 = fadd double %Y1, %B2 +; CHECK: %Z1.v.i0 = shufflevector <2 x double> %Y1, <2 x double> undef, <2 x i32> zeroinitializer +; CHECK: %Z1 = fadd <2 x double> %Z1.v.i0, %X1.v.i1.2 + %R = fmul double %Z1, %Z2 +; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0 +; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1 +; CHECK: %R = fmul double %Z1.v.r1, %Z1.v.r2 + ret double %R +; CHECK: ret double %R +} + +; Basic depth-3 chain +define <2 x float> @test5(<2 x float> %A1, <2 x float> %A2, <2 x float> %B1, <2 x float> %B2) { +; CHECK: @test5 +; CHECK: %X1.v.i1 = shufflevector <2 x float> %B1, <2 x float> %B2, <4 x i32> +; CHECK: %X1.v.i0 = shufflevector <2 x float> %A1, <2 x float> %A2, <4 x i32> + %X1 = fsub <2 x float> %A1, %B1 + %X2 = fsub <2 x float> %A2, %B2 +; CHECK: %X1 = fsub <4 x float> %X1.v.i0, %X1.v.i1 + %Y1 = fmul <2 x float> %X1, %A1 + %Y2 = fmul <2 x float> %X2, %A2 +; CHECK: %Y1 = fmul <4 x float> %X1, %X1.v.i0 + %Z1 = fadd <2 x float> %Y1, %B1 + %Z2 = fadd <2 x float> %Y2, %B2 +; CHECK: %Z1 = fadd <4 x float> %Y1, %X1.v.i1 + %R = fmul <2 x float> %Z1, %Z2 +; CHECK: %Z1.v.r1 = shufflevector <4 x float> %Z1, <4 x float> undef, <2 x i32> +; CHECK: %Z1.v.r2 = shufflevector <4 x float> %Z1, <4 x float> undef, <2 x i32> +; CHECK: %R = fmul <2 x float> %Z1.v.r1, %Z1.v.r2 + ret <2 x float> %R +; CHECK: ret <2 x float> %R +} + +; Basic chain with shuffles +define <8 x i8> @test6(<8 x i8> %A1, <8 x i8> %A2, <8 x i8> %B1, <8 x i8> %B2) { +; CHECK: @test6 +; CHECK: %X1.v.i1 = shufflevector <8 x i8> %B1, <8 x i8> %B2, <16 x i32> +; CHECK: %X1.v.i0 = shufflevector <8 x i8> %A1, <8 x i8> %A2, <16 x i32> + %X1 = sub <8 x i8> %A1, %B1 + %X2 = sub <8 x i8> %A2, %B2 +; CHECK: %X1 = sub <16 x i8> %X1.v.i0, %X1.v.i1 + %Y1 = mul <8 x i8> %X1, %A1 + %Y2 = mul <8 x i8> %X2, %A2 +; CHECK: %Y1 = mul <16 x i8> %X1, %X1.v.i0 + %Z1 = add <8 x i8> %Y1, %B1 + %Z2 = add <8 x i8> %Y2, %B2 +; CHECK: %Z1 = add <16 x i8> %Y1, %X1.v.i1 + %Q1 = shufflevector <8 x i8> %Z1, <8 x i8> %Z2, <8 x i32> + %Q2 = shufflevector <8 x i8> %Z2, <8 x i8> %Z2, <8 x i32> +; CHECK: %Z1.v.r2 = shufflevector <16 x i8> %Z1, <16 x i8> undef, <8 x i32> +; CHECK: %Q1.v.i1 = shufflevector <8 x i8> %Z1.v.r2, <8 x i8> undef, <16 x i32> +; CHECK: %Q1 = shufflevector <16 x i8> %Z1, <16 x i8> %Q1.v.i1, <16 x i32> + %R = mul <8 x i8> %Q1, %Q2 +; CHECK: %Q1.v.r1 = shufflevector <16 x i8> %Q1, <16 x i8> undef, <8 x i32> +; CHECK: %Q1.v.r2 = shufflevector <16 x i8> %Q1, <16 x i8> undef, <8 x i32> +; CHECK: %R = mul <8 x i8> %Q1.v.r1, %Q1.v.r2 + ret <8 x i8> %R +; CHECK: ret <8 x i8> %R +} + + diff --git a/test/Transforms/BlockPlacement/dg.exp b/test/Transforms/BlockPlacement/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/BlockPlacement/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/BlockPlacement/lit.local.cfg b/test/Transforms/BlockPlacement/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/BlockPlacement/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/CodeExtractor/dg.exp b/test/Transforms/CodeExtractor/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/CodeExtractor/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/CodeExtractor/lit.local.cfg b/test/Transforms/CodeExtractor/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/CodeExtractor/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/CodeGenPrepare/dg.exp b/test/Transforms/CodeGenPrepare/dg.exp deleted file mode 100644 index de42dad163fd..000000000000 --- a/test/Transforms/CodeGenPrepare/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.ll]] diff --git a/test/Transforms/CodeGenPrepare/lit.local.cfg b/test/Transforms/CodeGenPrepare/lit.local.cfg new file mode 100644 index 000000000000..c6106e4746f2 --- /dev/null +++ b/test/Transforms/CodeGenPrepare/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll'] diff --git a/test/Transforms/ConstProp/2007-11-23-cttz.ll b/test/Transforms/ConstProp/2007-11-23-cttz.ll index 37cda303713b..a28c9b0a2f13 100644 --- a/test/Transforms/ConstProp/2007-11-23-cttz.ll +++ b/test/Transforms/ConstProp/2007-11-23-cttz.ll @@ -1,8 +1,8 @@ ; RUN: opt < %s -constprop -S | grep {ret i13 13} ; PR1816 -declare i13 @llvm.cttz.i13(i13) +declare i13 @llvm.cttz.i13(i13, i1) define i13 @test() { - %X = call i13 @llvm.cttz.i13(i13 0) + %X = call i13 @llvm.cttz.i13(i13 0, i1 true) ret i13 %X } diff --git a/test/Transforms/ConstProp/basictest.ll b/test/Transforms/ConstProp/basictest.ll index d0d0a5bb3352..09e6e7db437a 100644 --- a/test/Transforms/ConstProp/basictest.ll +++ b/test/Transforms/ConstProp/basictest.ll @@ -1,5 +1,8 @@ ; RUN: opt < %s -constprop -die -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" +target triple = "x86_64-apple-macosx10.7.2" + ; This is a basic sanity check for constant propagation. The add instruction ; should be eliminated. define i32 @test1(i1 %B) { @@ -40,3 +43,11 @@ define i1 @TNAN() { %C = or i1 %A, %B ret i1 %C } + +define i128 @vector_to_int_cast() { + %A = bitcast <4 x i32> to i128 + ret i128 %A +; CHECK: @vector_to_int_cast +; CHECK: ret i128 85070591750041656499021422275829170176 +} + \ No newline at end of file diff --git a/test/Transforms/ConstProp/bswap.ll b/test/Transforms/ConstProp/bswap.ll index 9fce309b7887..a68fdcd4581e 100644 --- a/test/Transforms/ConstProp/bswap.ll +++ b/test/Transforms/ConstProp/bswap.ll @@ -1,6 +1,6 @@ ; bswap should be constant folded when it is passed a constant argument -; RUN: opt < %s -constprop -S | not grep call +; RUN: opt < %s -constprop -S | FileCheck %s declare i16 @llvm.bswap.i16(i16) @@ -8,18 +8,34 @@ declare i32 @llvm.bswap.i32(i32) declare i64 @llvm.bswap.i64(i64) +declare i80 @llvm.bswap.i80(i80) + +; CHECK: define i16 @W define i16 @W() { + ; CHECK: ret i16 256 %Z = call i16 @llvm.bswap.i16( i16 1 ) ; [#uses=1] ret i16 %Z } +; CHECK: define i32 @X define i32 @X() { + ; CHECK: ret i32 16777216 %Z = call i32 @llvm.bswap.i32( i32 1 ) ; [#uses=1] ret i32 %Z } +; CHECK: define i64 @Y define i64 @Y() { + ; CHECK: ret i64 72057594037927936 %Z = call i64 @llvm.bswap.i64( i64 1 ) ; [#uses=1] ret i64 %Z } +; CHECK: define i80 @Z +define i80 @Z() { + ; CHECK: ret i80 -450681596205739728166896 + ; 0xA0908070605040302010 + %Z = call i80 @llvm.bswap.i80( i80 76151636403560493650080 ) + ; 0x102030405060708090A0 + ret i80 %Z +} diff --git a/test/Transforms/ConstProp/calls.ll b/test/Transforms/ConstProp/calls.ll index 3b6010a0dc32..7a405a539c51 100644 --- a/test/Transforms/ConstProp/calls.ll +++ b/test/Transforms/ConstProp/calls.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -constprop -S | FileCheck %s +; RUN: opt < %s -constprop -disable-simplify-libcalls -S | FileCheck %s --check-prefix=FNOBUILTIN declare double @cos(double) @@ -59,3 +60,90 @@ declare i32 @llvm.x86.sse2.cvtsd2si(<2 x double>) nounwind readnone declare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) nounwind readnone declare i64 @llvm.x86.sse2.cvtsd2si64(<2 x double>) nounwind readnone declare i64 @llvm.x86.sse2.cvttsd2si64(<2 x double>) nounwind readnone + +define double @test_intrinsic_pow() nounwind uwtable ssp { +entry: +; CHECK: @test_intrinsic_pow +; CHECK-NOT: call + %0 = call double @llvm.pow.f64(double 1.500000e+00, double 3.000000e+00) + ret double %0 +} +declare double @llvm.pow.f64(double, double) nounwind readonly + +; Shouldn't fold because of -fno-builtin +define double @sin_() nounwind uwtable ssp { +; FNOBUILTIN: @sin_ +; FNOBUILTIN: %1 = call double @sin(double 3.000000e+00) + %1 = call double @sin(double 3.000000e+00) + ret double %1 +} + +; Shouldn't fold because of -fno-builtin +define double @sqrt_() nounwind uwtable ssp { +; FNOBUILTIN: @sqrt_ +; FNOBUILTIN: %1 = call double @sqrt(double 3.000000e+00) + %1 = call double @sqrt(double 3.000000e+00) + ret double %1 +} + +; Shouldn't fold because of -fno-builtin +define float @sqrtf_() nounwind uwtable ssp { +; FNOBUILTIN: @sqrtf_ +; FNOBUILTIN: %1 = call float @sqrtf(float 3.000000e+00) + %1 = call float @sqrtf(float 3.000000e+00) + ret float %1 +} +declare float @sqrtf(float) + +; Shouldn't fold because of -fno-builtin +define float @sinf_() nounwind uwtable ssp { +; FNOBUILTIN: @sinf_ +; FNOBUILTIN: %1 = call float @sinf(float 3.000000e+00) + %1 = call float @sinf(float 3.000000e+00) + ret float %1 +} +declare float @sinf(float) + +; Shouldn't fold because of -fno-builtin +define double @tan_() nounwind uwtable ssp { +; FNOBUILTIN: @tan_ +; FNOBUILTIN: %1 = call double @tan(double 3.000000e+00) + %1 = call double @tan(double 3.000000e+00) + ret double %1 +} + +; Shouldn't fold because of -fno-builtin +define double @tanh_() nounwind uwtable ssp { +; FNOBUILTIN: @tanh_ +; FNOBUILTIN: %1 = call double @tanh(double 3.000000e+00) + %1 = call double @tanh(double 3.000000e+00) + ret double %1 +} +declare double @tanh(double) + +; Shouldn't fold because of -fno-builtin +define double @pow_() nounwind uwtable ssp { +; FNOBUILTIN: @pow_ +; FNOBUILTIN: %1 = call double @pow(double 3.000000e+00, double 3.000000e+00) + %1 = call double @pow(double 3.000000e+00, double 3.000000e+00) + ret double %1 +} +declare double @pow(double, double) + +; Shouldn't fold because of -fno-builtin +define double @fmod_() nounwind uwtable ssp { +; FNOBUILTIN: @fmod_ +; FNOBUILTIN: %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00) + %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00) + ret double %1 +} +declare double @fmod(double, double) + +; Shouldn't fold because of -fno-builtin +define double @atan2_() nounwind uwtable ssp { +; FNOBUILTIN: @atan2_ +; FNOBUILTIN: %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00) + %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00) + ret double %1 +} +declare double @atan2(double, double) diff --git a/test/Transforms/ConstProp/dg.exp b/test/Transforms/ConstProp/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/ConstProp/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/ConstProp/lit.local.cfg b/test/Transforms/ConstProp/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/ConstProp/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/ConstantMerge/dg.exp b/test/Transforms/ConstantMerge/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/ConstantMerge/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/ConstantMerge/linker-private.ll b/test/Transforms/ConstantMerge/linker-private.ll new file mode 100644 index 000000000000..eba7880e8af7 --- /dev/null +++ b/test/Transforms/ConstantMerge/linker-private.ll @@ -0,0 +1,23 @@ +; RUN: opt < %s -constmerge -S | FileCheck %s +; + +%0 = type opaque +%struct.NSConstantString = type { i32*, i32, i8*, i32 } + +; CHECK: @.str3 = linker_private unnamed_addr constant [1 x i8] zeroinitializer, align 1 + +@isLogVisible = global i8 0, align 1 +@__CFConstantStringClassReference = external global [0 x i32] +@.str3 = linker_private unnamed_addr constant [1 x i8] zeroinitializer, align 1 +@_unnamed_cfstring_4 = private constant %struct.NSConstantString { i32* getelementptr inbounds ([0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([1 x i8]* @.str3, i32 0, i32 0), i32 0 }, section "__DATA,__cfstring" +@null.array = weak_odr constant [1 x i8] zeroinitializer, align 1 + +define linkonce_odr void @bar() nounwind ssp align 2 { +entry: + %stack = alloca i8*, align 4 + %call = call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %0* (i8*, i8*, %0*)*)(i8* null, i8* null, %0* bitcast (%struct.NSConstantString* @_unnamed_cfstring_4 to %0*)) + store i8* getelementptr inbounds ([1 x i8]* @null.array, i32 0, i32 0), i8** %stack, align 4 + ret void +} + +declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind diff --git a/test/Transforms/ConstantMerge/lit.local.cfg b/test/Transforms/ConstantMerge/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/ConstantMerge/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/CorrelatedValuePropagation/basic.ll b/test/Transforms/CorrelatedValuePropagation/basic.ll index 270c048e2f98..475cd8d772e6 100644 --- a/test/Transforms/CorrelatedValuePropagation/basic.ll +++ b/test/Transforms/CorrelatedValuePropagation/basic.ll @@ -79,4 +79,103 @@ Impossible: LessThanOrEqualToTwo: ret i32 0 -} \ No newline at end of file +} + +define i32 @switch1(i32 %s) { +; CHECK: @switch1 +entry: + %cmp = icmp slt i32 %s, 0 + br i1 %cmp, label %negative, label %out + +negative: + switch i32 %s, label %out [ +; CHECK: switch i32 %s, label %out + i32 0, label %out +; CHECK-NOT: i32 0 + i32 1, label %out +; CHECK-NOT: i32 1 + i32 -1, label %next +; CHECK: i32 -1, label %next + i32 -2, label %next +; CHECK: i32 -2, label %next + i32 2, label %out +; CHECK-NOT: i32 2 + i32 3, label %out +; CHECK-NOT: i32 3 + ] + +out: + %p = phi i32 [ 1, %entry ], [ -1, %negative ], [ -1, %negative ], [ -1, %negative ], [ -1, %negative ] + ret i32 %p + +next: + %q = phi i32 [ 0, %negative ], [ 0, %negative ] + ret i32 %q +} + +define i32 @switch2(i32 %s) { +; CHECK: @switch2 +entry: + %cmp = icmp sgt i32 %s, 0 + br i1 %cmp, label %positive, label %out + +positive: + switch i32 %s, label %out [ + i32 0, label %out + i32 -1, label %next + i32 -2, label %next + ] +; CHECK: br label %out + +out: + %p = phi i32 [ -1, %entry ], [ 1, %positive ], [ 1, %positive ] + ret i32 %p + +next: + %q = phi i32 [ 0, %positive ], [ 0, %positive ] + ret i32 %q +} + +define i32 @switch3(i32 %s) { +; CHECK: @switch3 +entry: + %cmp = icmp sgt i32 %s, 0 + br i1 %cmp, label %positive, label %out + +positive: + switch i32 %s, label %out [ + i32 -1, label %out + i32 -2, label %next + i32 -3, label %next + ] +; CHECK: br label %out + +out: + %p = phi i32 [ -1, %entry ], [ 1, %positive ], [ 1, %positive ] + ret i32 %p + +next: + %q = phi i32 [ 0, %positive ], [ 0, %positive ] + ret i32 %q +} + +define void @switch4(i32 %s) { +; CHECK: @switch4 +entry: + %cmp = icmp eq i32 %s, 0 + br i1 %cmp, label %zero, label %out + +zero: + switch i32 %s, label %out [ + i32 0, label %next + i32 1, label %out + i32 -1, label %out + ] +; CHECK: br label %next + +out: + ret void + +next: + ret void +} diff --git a/test/Transforms/CorrelatedValuePropagation/dg.exp b/test/Transforms/CorrelatedValuePropagation/dg.exp deleted file mode 100644 index de42dad163fd..000000000000 --- a/test/Transforms/CorrelatedValuePropagation/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.ll]] diff --git a/test/Transforms/CorrelatedValuePropagation/lit.local.cfg b/test/Transforms/CorrelatedValuePropagation/lit.local.cfg new file mode 100644 index 000000000000..c6106e4746f2 --- /dev/null +++ b/test/Transforms/CorrelatedValuePropagation/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll'] diff --git a/test/Transforms/CorrelatedValuePropagation/range.ll b/test/Transforms/CorrelatedValuePropagation/range.ll new file mode 100644 index 000000000000..9b70ed200eda --- /dev/null +++ b/test/Transforms/CorrelatedValuePropagation/range.ll @@ -0,0 +1,43 @@ +; RUN: opt -correlated-propagation -S < %s | FileCheck %s + +declare i32 @foo() + +define i32 @test1(i32 %a) nounwind { + %a.off = add i32 %a, -8 + %cmp = icmp ult i32 %a.off, 8 + br i1 %cmp, label %then, label %else + +then: + %dead = icmp eq i32 %a, 7 + br i1 %dead, label %end, label %else + +else: + ret i32 1 + +end: + ret i32 2 + +; CHECK: @test1 +; CHECK: then: +; CHECK-NEXT: br i1 false, label %end, label %else +} + +define i32 @test2(i32 %a) nounwind { + %a.off = add i32 %a, -8 + %cmp = icmp ult i32 %a.off, 8 + br i1 %cmp, label %then, label %else + +then: + %dead = icmp ugt i32 %a, 15 + br i1 %dead, label %end, label %else + +else: + ret i32 1 + +end: + ret i32 2 + +; CHECK: @test2 +; CHECK: then: +; CHECK-NEXT: br i1 false, label %end, label %else +} diff --git a/test/Transforms/DeadArgElim/deadexternal.ll b/test/Transforms/DeadArgElim/deadexternal.ll index b2d63ec77209..e3fe1bbb548b 100644 --- a/test/Transforms/DeadArgElim/deadexternal.ll +++ b/test/Transforms/DeadArgElim/deadexternal.ll @@ -30,10 +30,10 @@ entry: define void @h() { entry: %i = alloca i32, align 4 - volatile store i32 10, i32* %i, align 4 + store volatile i32 10, i32* %i, align 4 ; CHECK: %tmp = load volatile i32* %i, align 4 ; CHECK-next: call void @f(i32 undef) - %tmp = volatile load i32* %i, align 4 + %tmp = load volatile i32* %i, align 4 call void @f(i32 %tmp) ret void } diff --git a/test/Transforms/DeadArgElim/dg.exp b/test/Transforms/DeadArgElim/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/DeadArgElim/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/DeadArgElim/lit.local.cfg b/test/Transforms/DeadArgElim/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/DeadArgElim/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/DeadStoreElimination/OverwriteStoreEnd.ll b/test/Transforms/DeadStoreElimination/OverwriteStoreEnd.ll new file mode 100644 index 000000000000..ed53eb524c20 --- /dev/null +++ b/test/Transforms/DeadStoreElimination/OverwriteStoreEnd.ll @@ -0,0 +1,95 @@ +; RUN: opt < %s -basicaa -dse -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" + +%struct.vec2 = type { <4 x i32>, <4 x i32> } +%struct.vec2plusi = type { <4 x i32>, <4 x i32>, i32 } + +@glob1 = global %struct.vec2 zeroinitializer, align 16 +@glob2 = global %struct.vec2plusi zeroinitializer, align 16 + +define void @write24to28(i32* nocapture %p) nounwind uwtable ssp { +; CHECK: @write24to28 +entry: + %arrayidx0 = getelementptr inbounds i32* %p, i64 1 + %p3 = bitcast i32* %arrayidx0 to i8* +; CHECK: call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 24, i32 4, i1 false) + call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 28, i32 4, i1 false) + %arrayidx1 = getelementptr inbounds i32* %p, i64 7 + store i32 1, i32* %arrayidx1, align 4 + ret void +} + +define void @write28to32(i32* nocapture %p) nounwind uwtable ssp { +; CHECK: @write28to32 +entry: + %p3 = bitcast i32* %p to i8* +; CHECK: call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 28, i32 4, i1 false) + call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 32, i32 4, i1 false) + %arrayidx1 = getelementptr inbounds i32* %p, i64 7 + store i32 1, i32* %arrayidx1, align 4 + ret void +} + +define void @dontwrite28to32memset(i32* nocapture %p) nounwind uwtable ssp { +; CHECK: @dontwrite28to32memset +entry: + %p3 = bitcast i32* %p to i8* +; CHECK: call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 32, i32 16, i1 false) + call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 32, i32 16, i1 false) + %arrayidx1 = getelementptr inbounds i32* %p, i64 7 + store i32 1, i32* %arrayidx1, align 4 + ret void +} + +define void @write32to36(%struct.vec2plusi* nocapture %p) nounwind uwtable ssp { +; CHECK: @write32to36 +entry: + %0 = bitcast %struct.vec2plusi* %p to i8* +; CHECK: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2plusi* @glob2 to i8*), i64 32, i32 16, i1 false) + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2plusi* @glob2 to i8*), i64 36, i32 16, i1 false) + %c = getelementptr inbounds %struct.vec2plusi* %p, i64 0, i32 2 + store i32 1, i32* %c, align 4 + ret void +} + +define void @write16to32(%struct.vec2* nocapture %p) nounwind uwtable ssp { +; CHECK: @write16to32 +entry: + %0 = bitcast %struct.vec2* %p to i8* +; CHECK: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 16, i32 16, i1 false) + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 32, i32 16, i1 false) + %c = getelementptr inbounds %struct.vec2* %p, i64 0, i32 1 + store <4 x i32> , <4 x i32>* %c, align 4 + ret void +} + +define void @dontwrite28to32memcpy(%struct.vec2* nocapture %p) nounwind uwtable ssp { +; CHECK: @dontwrite28to32memcpy +entry: + %0 = bitcast %struct.vec2* %p to i8* +; CHECK: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 32, i32 16, i1 false) + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 32, i32 16, i1 false) + %arrayidx1 = getelementptr inbounds %struct.vec2* %p, i64 0, i32 0, i64 7 + store i32 1, i32* %arrayidx1, align 4 + ret void +} + +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind +declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind + +%struct.trapframe = type { i64, i64, i64 } + +; bugzilla 11455 - make sure negative GEP's don't break this optimisation +; CHECK: @cpu_lwp_fork +define void @cpu_lwp_fork(%struct.trapframe* %md_regs, i64 %pcb_rsp0) nounwind uwtable noinline ssp { +entry: + %0 = inttoptr i64 %pcb_rsp0 to %struct.trapframe* + %add.ptr = getelementptr inbounds %struct.trapframe* %0, i64 -1 + %1 = bitcast %struct.trapframe* %add.ptr to i8* + %2 = bitcast %struct.trapframe* %md_regs to i8* +; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* %2, i64 24, i32 1, i1 false) + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* %2, i64 24, i32 1, i1 false) + %tf_trapno = getelementptr inbounds %struct.trapframe* %0, i64 -1, i32 1 + store i64 3, i64* %tf_trapno, align 8 + ret void +} diff --git a/test/Transforms/DeadStoreElimination/dg.exp b/test/Transforms/DeadStoreElimination/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/DeadStoreElimination/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/DeadStoreElimination/dominate.ll b/test/Transforms/DeadStoreElimination/dominate.ll new file mode 100644 index 000000000000..284fea4234fc --- /dev/null +++ b/test/Transforms/DeadStoreElimination/dominate.ll @@ -0,0 +1,25 @@ +; RUN: opt %s -dse -disable-output +; test that we don't crash +declare void @bar() + +define void @foo() { +bb1: + %memtmp3.i = alloca [21 x i8], align 1 + %0 = getelementptr inbounds [21 x i8]* %memtmp3.i, i64 0, i64 0 + br label %bb3 + +bb2: + call void @llvm.lifetime.end(i64 -1, i8* %0) + br label %bb3 + +bb3: + call void @bar() + call void @llvm.lifetime.end(i64 -1, i8* %0) + br label %bb4 + +bb4: + ret void + +} + +declare void @llvm.lifetime.end(i64, i8* nocapture) nounwind diff --git a/test/Transforms/DeadStoreElimination/free.ll b/test/Transforms/DeadStoreElimination/free.ll index aa3f0ab938e2..a5fbdc76387e 100644 --- a/test/Transforms/DeadStoreElimination/free.ll +++ b/test/Transforms/DeadStoreElimination/free.ll @@ -2,6 +2,9 @@ target datalayout = "e-p:64:64:64" +declare void @free(i8* nocapture) +declare noalias i8* @malloc(i64) + ; CHECK: @test ; CHECK-NEXT: bitcast ; CHECK-NEXT: @free @@ -26,10 +29,10 @@ define void @test2({i32, i32}* %P) { ret void } -; CHECK: @test4 +; CHECK: @test3 ; CHECK-NOT: store ; CHECK: ret void -define void @test4() { +define void @test3() { %m = call i8* @malloc(i64 24) store i8 0, i8* %m %m1 = getelementptr i8* %m, i64 1 @@ -38,5 +41,30 @@ define void @test4() { ret void } -declare void @free(i8*) -declare i8* @malloc(i64) +; PR11240 +; CHECK: @test4 +; CHECK-NOT: store +; CHECK: ret void +define void @test4(i1 %x) nounwind { +entry: + %alloc1 = tail call noalias i8* @malloc(i64 4) nounwind + br i1 %x, label %skipinit1, label %init1 + +init1: + store i8 1, i8* %alloc1 + br label %skipinit1 + +skipinit1: + tail call void @free(i8* %alloc1) nounwind + ret void +} + +; CHECK: @test5 +define void @test5() { + br label %bb + +bb: + tail call void @free(i8* undef) nounwind + br label %bb +} + diff --git a/test/Transforms/DeadStoreElimination/lit.local.cfg b/test/Transforms/DeadStoreElimination/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/DeadStoreElimination/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/DeadStoreElimination/pr11390.ll b/test/Transforms/DeadStoreElimination/pr11390.ll new file mode 100644 index 000000000000..2ce6eea365aa --- /dev/null +++ b/test/Transforms/DeadStoreElimination/pr11390.ll @@ -0,0 +1,38 @@ +; RUN: opt -basicaa -dse -S -o - %s | FileCheck %s +; PR11390 +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" +target triple = "x86_64-unknown-linux-gnu" + +define fastcc void @cat_domain(i8* nocapture %name, i8* nocapture %domain, i8** +nocapture %s) nounwind uwtable { +entry: + %call = tail call i64 @strlen(i8* %name) nounwind readonly + %call1 = tail call i64 @strlen(i8* %domain) nounwind readonly + %add = add i64 %call, 1 + %add2 = add i64 %add, %call1 + %add3 = add i64 %add2, 1 + %call4 = tail call noalias i8* @malloc(i64 %add3) nounwind + store i8* %call4, i8** %s, align 8 + %tobool = icmp eq i8* %call4, null + br i1 %tobool, label %return, label %if.end + +if.end: ; preds = %entry + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %call4, i8* %name, i64 %call, i32 1, i1 false) + %arrayidx = getelementptr inbounds i8* %call4, i64 %call + store i8 46, i8* %arrayidx, align 1 +; CHECK: store i8 46 + %add.ptr5 = getelementptr inbounds i8* %call4, i64 %add + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %add.ptr5, i8* %domain, i64 %call1, i32 1, i1 false) + %arrayidx8 = getelementptr inbounds i8* %call4, i64 %add2 + store i8 0, i8* %arrayidx8, align 1 + br label %return + +return: ; preds = %if.end, %entry + ret void +} + +declare i64 @strlen(i8* nocapture) nounwind readonly + +declare noalias i8* @malloc(i64) nounwind + +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind diff --git a/test/Transforms/DeadStoreElimination/simple.ll b/test/Transforms/DeadStoreElimination/simple.ll index ec2f15737a37..81eb5a8c705e 100644 --- a/test/Transforms/DeadStoreElimination/simple.ll +++ b/test/Transforms/DeadStoreElimination/simple.ll @@ -251,3 +251,10 @@ bb: ; CHECK: call void @test19f } +define void @test20() { + %m = call i8* @malloc(i32 24) + store i8 0, i8* %m + ret void +} +; CHECK: @test20 +; CHECK-NEXT: ret void diff --git a/test/Transforms/EarlyCSE/basic.ll b/test/Transforms/EarlyCSE/basic.ll index 57b1697ff4de..32c302c9205b 100644 --- a/test/Transforms/EarlyCSE/basic.ll +++ b/test/Transforms/EarlyCSE/basic.ll @@ -10,22 +10,22 @@ define void @test1(i8 %V, i32 *%P) { %C = zext i8 %V to i32 %D = zext i8 %V to i32 ;; CSE - volatile store i32 %C, i32* %P - volatile store i32 %D, i32* %P + store volatile i32 %C, i32* %P + store volatile i32 %D, i32* %P ; CHECK-NEXT: %C = zext i8 %V to i32 ; CHECK-NEXT: store volatile i32 %C ; CHECK-NEXT: store volatile i32 %C %E = add i32 %C, %C %F = add i32 %C, %C - volatile store i32 %E, i32* %P - volatile store i32 %F, i32* %P + store volatile i32 %E, i32* %P + store volatile i32 %F, i32* %P ; CHECK-NEXT: %E = add i32 %C, %C ; CHECK-NEXT: store volatile i32 %E ; CHECK-NEXT: store volatile i32 %E %G = add nuw i32 %C, %C ;; not a CSE with E - volatile store i32 %G, i32* %P + store volatile i32 %G, i32* %P ; CHECK-NEXT: %G = add nuw i32 %C, %C ; CHECK-NEXT: store volatile i32 %G ret void diff --git a/test/Transforms/EarlyCSE/dg.exp b/test/Transforms/EarlyCSE/dg.exp deleted file mode 100644 index de42dad163fd..000000000000 --- a/test/Transforms/EarlyCSE/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.ll]] diff --git a/test/Transforms/EarlyCSE/instsimplify-dom.ll b/test/Transforms/EarlyCSE/instsimplify-dom.ll new file mode 100644 index 000000000000..36dffec1c63c --- /dev/null +++ b/test/Transforms/EarlyCSE/instsimplify-dom.ll @@ -0,0 +1,19 @@ +; RUN: opt -early-cse -S < %s | FileCheck %s +; PR12231 + +declare i32 @f() + +define i32 @fn() { +entry: + br label %lbl_1215 + +lbl_1215: + %ins34 = phi i32 [ %ins35, %xxx ], [ undef, %entry ] + ret i32 %ins34 + +xxx: + %ins35 = call i32 @f() + br label %lbl_1215 +} + +; CHECK: define i32 @fn diff --git a/test/Transforms/EarlyCSE/lit.local.cfg b/test/Transforms/EarlyCSE/lit.local.cfg new file mode 100644 index 000000000000..c6106e4746f2 --- /dev/null +++ b/test/Transforms/EarlyCSE/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll'] diff --git a/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll b/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll index 85df09ebd7fe..b7e4d1f87261 100644 --- a/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll +++ b/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll @@ -4,6 +4,6 @@ @g = global i32 0 ; [#uses=1] define i32 @f() { - %t = volatile load i32* @g ; [#uses=1] + %t = load volatile i32* @g ; [#uses=1] ret i32 %t } diff --git a/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll b/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll deleted file mode 100644 index e2bab19e7efd..000000000000 --- a/test/Transforms/FunctionAttrs/2008-12-31-NoCapture.ll +++ /dev/null @@ -1,105 +0,0 @@ -; RUN: opt < %s -functionattrs -S | not grep {nocapture *%%q} -; RUN: opt < %s -functionattrs -S | grep {nocapture *%%p} | count 6 -@g = global i32* null ; [#uses=1] - -define i32* @c1(i32* %q) { - ret i32* %q -} - -define void @c2(i32* %q) { - store i32* %q, i32** @g - ret void -} - -define void @c3(i32* %q) { - call void @c2(i32* %q) - ret void -} - -define i1 @c4(i32* %q, i32 %bitno) { - %tmp = ptrtoint i32* %q to i32 - %tmp2 = lshr i32 %tmp, %bitno - %bit = trunc i32 %tmp2 to i1 - br i1 %bit, label %l1, label %l0 -l0: - ret i1 0 ; escaping value not caught by def-use chaining. -l1: - ret i1 1 ; escaping value not caught by def-use chaining. -} - -@lookup_table = global [2 x i1] [ i1 0, i1 1 ] - -define i1 @c5(i32* %q, i32 %bitno) { - %tmp = ptrtoint i32* %q to i32 - %tmp2 = lshr i32 %tmp, %bitno - %bit = and i32 %tmp2, 1 - ; subtle escape mechanism follows - %lookup = getelementptr [2 x i1]* @lookup_table, i32 0, i32 %bit - %val = load i1* %lookup - ret i1 %val -} - -declare void @throw_if_bit_set(i8*, i8) readonly -define i1 @c6(i8* %q, i8 %bit) { - invoke void @throw_if_bit_set(i8* %q, i8 %bit) - to label %ret0 unwind label %ret1 -ret0: - ret i1 0 -ret1: - %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 - cleanup - ret i1 1 -} - -declare i32 @__gxx_personality_v0(...) - -define i1* @lookup_bit(i32* %q, i32 %bitno) readnone nounwind { - %tmp = ptrtoint i32* %q to i32 - %tmp2 = lshr i32 %tmp, %bitno - %bit = and i32 %tmp2, 1 - %lookup = getelementptr [2 x i1]* @lookup_table, i32 0, i32 %bit - ret i1* %lookup -} - -define i1 @c7(i32* %q, i32 %bitno) { - %ptr = call i1* @lookup_bit(i32* %q, i32 %bitno) - %val = load i1* %ptr - ret i1 %val -} - - -define i32 @nc1(i32* %q, i32* %p, i1 %b) { -e: - br label %l -l: - %x = phi i32* [ %p, %e ] - %y = phi i32* [ %q, %e ] - %tmp = bitcast i32* %x to i32* ; [#uses=2] - %tmp2 = select i1 %b, i32* %tmp, i32* %y - %val = load i32* %tmp2 ; [#uses=1] - store i32 0, i32* %tmp - store i32* %y, i32** @g - ret i32 %val -} - -define void @nc2(i32* %p, i32* %q) { - %1 = call i32 @nc1(i32* %q, i32* %p, i1 0) ; [#uses=0] - ret void -} - -define void @nc3(void ()* %p) { - call void %p() - ret void -} - -declare void @external(i8*) readonly nounwind -define void @nc4(i8* %p) { - call void @external(i8* %p) - ret void -} - -define void @nc5(void (i8*)* %f, i8* %p) { - call void %f(i8* %p) readonly nounwind - call void %f(i8* nocapture %p) - ret void -} diff --git a/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll b/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll index f21fabc493c7..93991d21a1fa 100644 --- a/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll +++ b/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll @@ -5,6 +5,6 @@ define void @foo() { ; CHECK: void @foo() { - %tmp = volatile load i32* @g + %tmp = load volatile i32* @g ret void } diff --git a/test/Transforms/FunctionAttrs/dg.exp b/test/Transforms/FunctionAttrs/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/FunctionAttrs/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/FunctionAttrs/lit.local.cfg b/test/Transforms/FunctionAttrs/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/FunctionAttrs/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/FunctionAttrs/nocapture.ll b/test/Transforms/FunctionAttrs/nocapture.ll new file mode 100644 index 000000000000..3027acd35c7d --- /dev/null +++ b/test/Transforms/FunctionAttrs/nocapture.ll @@ -0,0 +1,178 @@ +; RUN: opt < %s -functionattrs -S | FileCheck %s +@g = global i32* null ; [#uses=1] + +; CHECK: define i32* @c1(i32* %q) +define i32* @c1(i32* %q) { + ret i32* %q +} + +; CHECK: define void @c2(i32* %q) +define void @c2(i32* %q) { + store i32* %q, i32** @g + ret void +} + +; CHECK: define void @c3(i32* %q) +define void @c3(i32* %q) { + call void @c2(i32* %q) + ret void +} + +; CHECK: define i1 @c4(i32* %q, i32 %bitno) +define i1 @c4(i32* %q, i32 %bitno) { + %tmp = ptrtoint i32* %q to i32 + %tmp2 = lshr i32 %tmp, %bitno + %bit = trunc i32 %tmp2 to i1 + br i1 %bit, label %l1, label %l0 +l0: + ret i1 0 ; escaping value not caught by def-use chaining. +l1: + ret i1 1 ; escaping value not caught by def-use chaining. +} + +@lookup_table = global [2 x i1] [ i1 0, i1 1 ] + +; CHECK: define i1 @c5(i32* %q, i32 %bitno) +define i1 @c5(i32* %q, i32 %bitno) { + %tmp = ptrtoint i32* %q to i32 + %tmp2 = lshr i32 %tmp, %bitno + %bit = and i32 %tmp2, 1 + ; subtle escape mechanism follows + %lookup = getelementptr [2 x i1]* @lookup_table, i32 0, i32 %bit + %val = load i1* %lookup + ret i1 %val +} + +declare void @throw_if_bit_set(i8*, i8) readonly + +; CHECK: define i1 @c6(i8* %q, i8 %bit) +define i1 @c6(i8* %q, i8 %bit) { + invoke void @throw_if_bit_set(i8* %q, i8 %bit) + to label %ret0 unwind label %ret1 +ret0: + ret i1 0 +ret1: + %exn = landingpad {i8*, i32} personality i32 (...)* @__gxx_personality_v0 + cleanup + ret i1 1 +} + +declare i32 @__gxx_personality_v0(...) + +define i1* @lookup_bit(i32* %q, i32 %bitno) readnone nounwind { + %tmp = ptrtoint i32* %q to i32 + %tmp2 = lshr i32 %tmp, %bitno + %bit = and i32 %tmp2, 1 + %lookup = getelementptr [2 x i1]* @lookup_table, i32 0, i32 %bit + ret i1* %lookup +} + +; CHECK: define i1 @c7(i32* %q, i32 %bitno) +define i1 @c7(i32* %q, i32 %bitno) { + %ptr = call i1* @lookup_bit(i32* %q, i32 %bitno) + %val = load i1* %ptr + ret i1 %val +} + + +; CHECK: define i32 @nc1(i32* %q, i32* nocapture %p, i1 %b) +define i32 @nc1(i32* %q, i32* %p, i1 %b) { +e: + br label %l +l: + %x = phi i32* [ %p, %e ] + %y = phi i32* [ %q, %e ] + %tmp = bitcast i32* %x to i32* ; [#uses=2] + %tmp2 = select i1 %b, i32* %tmp, i32* %y + %val = load i32* %tmp2 ; [#uses=1] + store i32 0, i32* %tmp + store i32* %y, i32** @g + ret i32 %val +} + +; CHECK: define void @nc2(i32* nocapture %p, i32* %q) +define void @nc2(i32* %p, i32* %q) { + %1 = call i32 @nc1(i32* %q, i32* %p, i1 0) ; [#uses=0] + ret void +} + +; CHECK: define void @nc3(void ()* nocapture %p) +define void @nc3(void ()* %p) { + call void %p() + ret void +} + +declare void @external(i8*) readonly nounwind +; CHECK: define void @nc4(i8* nocapture %p) +define void @nc4(i8* %p) { + call void @external(i8* %p) + ret void +} + +; CHECK: define void @nc5(void (i8*)* nocapture %f, i8* nocapture %p) +define void @nc5(void (i8*)* %f, i8* %p) { + call void %f(i8* %p) readonly nounwind + call void %f(i8* nocapture %p) + ret void +} + +; CHECK: define void @test1_1(i8* nocapture %x1_1, i8* %y1_1) +define void @test1_1(i8* %x1_1, i8* %y1_1) { + call i8* @test1_2(i8* %x1_1, i8* %y1_1) + store i32* null, i32** @g + ret void +} + +; CHECK: define i8* @test1_2(i8* nocapture %x1_2, i8* %y1_2) +define i8* @test1_2(i8* %x1_2, i8* %y1_2) { + call void @test1_1(i8* %x1_2, i8* %y1_2) + store i32* null, i32** @g + ret i8* %y1_2 +} + +; CHECK: define void @test2(i8* nocapture %x2) +define void @test2(i8* %x2) { + call void @test2(i8* %x2) + store i32* null, i32** @g + ret void +} + +; CHECK: define void @test3(i8* nocapture %x3, i8* nocapture %y3, i8* nocapture %z3) +define void @test3(i8* %x3, i8* %y3, i8* %z3) { + call void @test3(i8* %z3, i8* %y3, i8* %x3) + store i32* null, i32** @g + ret void +} + +; CHECK: define void @test4_1(i8* %x4_1) +define void @test4_1(i8* %x4_1) { + call i8* @test4_2(i8* %x4_1, i8* %x4_1, i8* %x4_1) + store i32* null, i32** @g + ret void +} + +; CHECK: define i8* @test4_2(i8* nocapture %x4_2, i8* %y4_2, i8* nocapture %z4_2) +define i8* @test4_2(i8* %x4_2, i8* %y4_2, i8* %z4_2) { + call void @test4_1(i8* null) + store i32* null, i32** @g + ret i8* %y4_2 +} + +declare i8* @test5_1(i8* %x5_1) + +; CHECK: define void @test5_2(i8* %x5_2) +define void @test5_2(i8* %x5_2) { + call i8* @test5_1(i8* %x5_2) + store i32* null, i32** @g + ret void +} + +declare void @test6_1(i8* %x6_1, i8* nocapture %y6_1, ...) + +; CHECK: define void @test6_2(i8* %x6_2, i8* nocapture %y6_2, i8* %z6_2) +define void @test6_2(i8* %x6_2, i8* %y6_2, i8* %z6_2) { + call void (i8*, i8*, ...)* @test6_1(i8* %x6_2, i8* %y6_2, i8* %z6_2) + store i32* null, i32** @g + ret void +} + diff --git a/test/Transforms/GVN/commute.ll b/test/Transforms/GVN/commute.ll new file mode 100644 index 000000000000..cf4fb7f17291 --- /dev/null +++ b/test/Transforms/GVN/commute.ll @@ -0,0 +1,23 @@ +; RUN: opt -gvn -S < %s | FileCheck %s + +declare void @use(i32, i32) + +define void @foo(i32 %x, i32 %y) { + ; CHECK: @foo + %add1 = add i32 %x, %y + %add2 = add i32 %y, %x + call void @use(i32 %add1, i32 %add2) + ; CHECK: @use(i32 %add1, i32 %add1) + ret void +} + +declare void @vse(i1, i1) + +define void @bar(i32 %x, i32 %y) { + ; CHECK: @bar + %cmp1 = icmp ult i32 %x, %y + %cmp2 = icmp ugt i32 %y, %x + call void @vse(i1 %cmp1, i1 %cmp2) + ; CHECK: @vse(i1 %cmp1, i1 %cmp1) + ret void +} diff --git a/test/Transforms/GVN/condprop.ll b/test/Transforms/GVN/condprop.ll index 0b31b01b7b14..9c28955801f7 100644 --- a/test/Transforms/GVN/condprop.ll +++ b/test/Transforms/GVN/condprop.ll @@ -55,25 +55,6 @@ return: ; preds = %bb8 } declare void @foo(i1) - -; CHECK: @test2 -define void @test2(i1 %x, i1 %y) { - %z = or i1 %x, %y - br i1 %z, label %true, label %false -true: -; CHECK: true: - %z2 = or i1 %x, %y - call void @foo(i1 %z2) -; CHECK: call void @foo(i1 true) - br label %true -false: -; CHECK: false: - %z3 = or i1 %x, %y - call void @foo(i1 %z3) -; CHECK: call void @foo(i1 false) - br label %false -} - declare void @bar(i32) ; CHECK: @test3 @@ -130,3 +111,141 @@ case3: ; CHECK: call void @bar(i32 %x) ret void } + +; CHECK: @test5 +define i1 @test5(i32 %x, i32 %y) { + %cmp = icmp eq i32 %x, %y + br i1 %cmp, label %same, label %different + +same: + %cmp2 = icmp ne i32 %x, %y +; CHECK: ret i1 false + ret i1 %cmp2 + +different: + %cmp3 = icmp eq i32 %x, %y +; CHECK: ret i1 false + ret i1 %cmp3 +} + +; CHECK: @test6 +define i1 @test6(i32 %x, i32 %y) { + %cmp2 = icmp ne i32 %x, %y + %cmp = icmp eq i32 %x, %y + %cmp3 = icmp eq i32 %x, %y + br i1 %cmp, label %same, label %different + +same: +; CHECK: ret i1 false + ret i1 %cmp2 + +different: +; CHECK: ret i1 false + ret i1 %cmp3 +} + +; CHECK: @test7 +define i1 @test7(i32 %x, i32 %y) { + %cmp = icmp sgt i32 %x, %y + br i1 %cmp, label %same, label %different + +same: + %cmp2 = icmp sle i32 %x, %y +; CHECK: ret i1 false + ret i1 %cmp2 + +different: + %cmp3 = icmp sgt i32 %x, %y +; CHECK: ret i1 false + ret i1 %cmp3 +} + +; CHECK: @test8 +define i1 @test8(i32 %x, i32 %y) { + %cmp2 = icmp sle i32 %x, %y + %cmp = icmp sgt i32 %x, %y + %cmp3 = icmp sgt i32 %x, %y + br i1 %cmp, label %same, label %different + +same: +; CHECK: ret i1 false + ret i1 %cmp2 + +different: +; CHECK: ret i1 false + ret i1 %cmp3 +} + +; PR1768 +; CHECK: @test9 +define i32 @test9(i32 %i, i32 %j) { + %cmp = icmp eq i32 %i, %j + br i1 %cmp, label %cond_true, label %ret + +cond_true: + %diff = sub i32 %i, %j + ret i32 %diff +; CHECK: ret i32 0 + +ret: + ret i32 5 +; CHECK: ret i32 5 +} + +; PR1768 +; CHECK: @test10 +define i32 @test10(i32 %j, i32 %i) { + %cmp = icmp eq i32 %i, %j + br i1 %cmp, label %cond_true, label %ret + +cond_true: + %diff = sub i32 %i, %j + ret i32 %diff +; CHECK: ret i32 0 + +ret: + ret i32 5 +; CHECK: ret i32 5 +} + +declare i32 @yogibar() + +; CHECK: @test11 +define i32 @test11(i32 %x) { + %v0 = call i32 @yogibar() + %v1 = call i32 @yogibar() + %cmp = icmp eq i32 %v0, %v1 + br i1 %cmp, label %cond_true, label %next + +cond_true: + ret i32 %v1 +; CHECK: ret i32 %v0 + +next: + %cmp2 = icmp eq i32 %x, %v0 + br i1 %cmp2, label %cond_true2, label %next2 + +cond_true2: + ret i32 %v0 +; CHECK: ret i32 %x + +next2: + ret i32 0 +} + +; CHECK: @test12 +define i32 @test12(i32 %x) { + %cmp = icmp eq i32 %x, 0 + br i1 %cmp, label %cond_true, label %cond_false + +cond_true: + br label %ret + +cond_false: + br label %ret + +ret: + %res = phi i32 [ %x, %cond_true ], [ %x, %cond_false ] +; CHECK: %res = phi i32 [ 0, %cond_true ], [ %x, %cond_false ] + ret i32 %res +} diff --git a/test/Transforms/GVN/dg.exp b/test/Transforms/GVN/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/GVN/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/GVN/lit.local.cfg b/test/Transforms/GVN/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/GVN/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/GVN/pre-compare.ll b/test/Transforms/GVN/pre-compare.ll new file mode 100644 index 000000000000..18d0c2e1085c --- /dev/null +++ b/test/Transforms/GVN/pre-compare.ll @@ -0,0 +1,68 @@ +; RUN: opt -gvn -S < %s | FileCheck %s + +; C source: +; +; void f(int x) { +; if (x != 1) +; puts (x == 2 ? "a" : "b"); +; for (;;) { +; puts("step 1"); +; if (x == 2) +; continue; +; printf("step 2: %d\n", x); +; } +; } +; +; If we PRE %cmp3, CodeGenPrepare won't be able to sink the compare down to its +; uses, and we are forced to keep both %x and %cmp3 in registers in the loop. +; +; It is just as cheap to recompute the icmp against %x as it is to compare a +; GPR against 0. On x86-64, the br i1 %cmp3 becomes: +; +; testb %r12b, %r12b +; jne LBB0_3 +; +; The sunk icmp is: +; +; cmpl $2, %ebx +; je LBB0_3 +; +; This is just as good, and it doesn't require a separate register. +; +; CHECK-NOT: phi i1 + +@.str = private unnamed_addr constant [2 x i8] c"a\00", align 1 +@.str1 = private unnamed_addr constant [2 x i8] c"b\00", align 1 +@.str2 = private unnamed_addr constant [7 x i8] c"step 1\00", align 1 +@.str3 = private unnamed_addr constant [12 x i8] c"step 2: %d\0A\00", align 1 + +define void @f(i32 %x) noreturn nounwind uwtable ssp { +entry: + %cmp = icmp eq i32 %x, 1 + br i1 %cmp, label %for.cond.preheader, label %if.then + +if.then: ; preds = %entry + %cmp1 = icmp eq i32 %x, 2 + %cond = select i1 %cmp1, i8* getelementptr inbounds ([2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8]* @.str1, i64 0, i64 0) + %call = tail call i32 @puts(i8* %cond) nounwind + br label %for.cond.preheader + +for.cond.preheader: ; preds = %entry, %if.then + %cmp3 = icmp eq i32 %x, 2 + br label %for.cond + +for.cond: ; preds = %for.cond.backedge, %for.cond.preheader + %call2 = tail call i32 @puts(i8* getelementptr inbounds ([7 x i8]* @.str2, i64 0, i64 0)) nounwind + br i1 %cmp3, label %for.cond.backedge, label %if.end5 + +if.end5: ; preds = %for.cond + %call6 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str3, i64 0, i64 0), i32 %x) nounwind + br label %for.cond.backedge + +for.cond.backedge: ; preds = %if.end5, %for.cond + br label %for.cond +} + +declare i32 @puts(i8* nocapture) nounwind + +declare i32 @printf(i8* nocapture, ...) nounwind diff --git a/test/Transforms/GVN/rle.ll b/test/Transforms/GVN/rle.ll index 2f0d2eb367cc..9e08004ea476 100644 --- a/test/Transforms/GVN/rle.ll +++ b/test/Transforms/GVN/rle.ll @@ -26,6 +26,15 @@ define i8 @crash0({i32, i32} %A, {i32, i32}* %P) { ret i8 %Y } +;; No PR filed, crashed in CaptureTracker. +declare void @helper() +define void @crash1() { + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* undef, i8* undef, i64 undef, i32 1, i1 false) nounwind + %tmp = load i8* bitcast (void ()* @helper to i8*) + %x = icmp eq i8 %tmp, 15 + ret void +} + ;;===----------------------------------------------------------------------===;; ;; Store -> Load and Load -> Load forwarding where src and dst are different @@ -642,3 +651,28 @@ declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind +;;===----------------------------------------------------------------------===;; +;; Load -> Store dependency which isn't interfered with by a call that happens +;; before the pointer was captured. +;;===----------------------------------------------------------------------===;; + +%class.X = type { [8 x i8] } + +@_ZTV1X = weak_odr constant [5 x i8*] zeroinitializer +@_ZTV1Y = weak_odr constant [5 x i8*] zeroinitializer + +declare void @use() +declare void @use3(i8***, i8**) + +; PR8908 +define void @test_escape1() nounwind { + %x = alloca i8**, align 8 + store i8** getelementptr inbounds ([5 x i8*]* @_ZTV1X, i64 0, i64 2), i8*** %x, align 8 + call void @use() nounwind + %DEAD = load i8*** %x, align 8 + call void @use3(i8*** %x, i8** %DEAD) nounwind + ret void +; CHECK: test_escape1 +; CHECK-NOT: DEAD +; CHECK: ret +} diff --git a/test/Transforms/GlobalDCE/2009-09-03-MDNode.ll b/test/Transforms/GlobalDCE/2009-09-03-MDNode.ll deleted file mode 100644 index 29864f825285..000000000000 --- a/test/Transforms/GlobalDCE/2009-09-03-MDNode.ll +++ /dev/null @@ -1,264 +0,0 @@ -; RUN: opt < %s -globaldce | llc -O0 -o /dev/null - -%struct..0__pthread_mutex_s = type { i32, i32, i32, i32, i32, i32, %struct.__pthread_list_t } -%"struct.__gnu_cxx::_ConvertibleConcept" = type { i32 } -%struct.__pthread_list_t = type { %struct.__pthread_list_t*, %struct.__pthread_list_t* } -%struct.pthread_attr_t = type { i64, [48 x i8] } -%struct.pthread_mutex_t = type { %struct..0__pthread_mutex_s } - -@_ZL20__gthrw_pthread_oncePiPFvvE = alias weak i32 (i32*, void ()*)* @pthread_once ; [#uses=0] -@_ZL27__gthrw_pthread_getspecificj = alias weak i8* (i32)* @pthread_getspecific ; [#uses=0] -@_ZL27__gthrw_pthread_setspecificjPKv = alias weak i32 (i32, i8*)* @pthread_setspecific ; [#uses=0] -@_ZL22__gthrw_pthread_createPmPK14pthread_attr_tPFPvS3_ES3_ = alias weak i32 (i64*, %struct.pthread_attr_t*, i8* (i8*)*, i8*)* @pthread_create ; [#uses=0] -@_ZL22__gthrw_pthread_cancelm = alias weak i32 (i64)* @pthread_cancel ; [#uses=0] -@_ZL26__gthrw_pthread_mutex_lockP15pthread_mutex_t = alias weak i32 (%struct.pthread_mutex_t*)* @pthread_mutex_lock ; [#uses=0] -@_ZL29__gthrw_pthread_mutex_trylockP15pthread_mutex_t = alias weak i32 (%struct.pthread_mutex_t*)* @pthread_mutex_trylock ; [#uses=0] -@_ZL28__gthrw_pthread_mutex_unlockP15pthread_mutex_t = alias weak i32 (%struct.pthread_mutex_t*)* @pthread_mutex_unlock ; [#uses=0] -@_ZL26__gthrw_pthread_mutex_initP15pthread_mutex_tPK19pthread_mutexattr_t = alias weak i32 (%struct.pthread_mutex_t*, %"struct.__gnu_cxx::_ConvertibleConcept"*)* @pthread_mutex_init ; "*)*> [#uses=0] -@_ZL26__gthrw_pthread_key_createPjPFvPvE = alias weak i32 (i32*, void (i8*)*)* @pthread_key_create ; [#uses=0] -@_ZL26__gthrw_pthread_key_deletej = alias weak i32 (i32)* @pthread_key_delete ; [#uses=0] -@_ZL30__gthrw_pthread_mutexattr_initP19pthread_mutexattr_t = alias weak i32 (%"struct.__gnu_cxx::_ConvertibleConcept"*)* @pthread_mutexattr_init ; "*)*> [#uses=0] -@_ZL33__gthrw_pthread_mutexattr_settypeP19pthread_mutexattr_ti = alias weak i32 (%"struct.__gnu_cxx::_ConvertibleConcept"*, i32)* @pthread_mutexattr_settype ; "*, i32)*> [#uses=0] -@_ZL33__gthrw_pthread_mutexattr_destroyP19pthread_mutexattr_t = alias weak i32 (%"struct.__gnu_cxx::_ConvertibleConcept"*)* @pthread_mutexattr_destroy ; "*)*> [#uses=0] - -define weak void @_ZN9__gnu_cxx26__aux_require_boolean_exprIbEEvRKT_(i8* %__t) { -entry: - tail call void @llvm.dbg.func.start(metadata !0) - tail call void @llvm.dbg.stoppoint(i32 240, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !0) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_19_ConvertibleConceptIjjEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !8) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !8) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPcEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !11) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !11) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPKcEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !12) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !12) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPwEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !13) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !13) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPKwEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !14) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !14) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIPwEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !15) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !15) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIPcEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !16) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !16) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIiEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !17) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !17) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIlEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !18) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !18) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIxEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !19) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !19) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIjEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !20) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !20) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_22_OutputIteratorConceptISt19ostreambuf_iteratorIcSt11char_traitsIcEEcEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !21) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !21) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_22_OutputIteratorConceptISt19ostreambuf_iteratorIwSt11char_traitsIwEEwEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !22) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !22) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPcEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !23) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !23) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPKcEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !24) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !24) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPKcSsEEEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !25) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !25) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPcSsEEEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !26) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !26) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPKwSbIwSt11char_traitsIwESaIwEEEEEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !27) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !27) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPwSbIwSt11char_traitsIwESaIwEEEEEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !28) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !28) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPwEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !29) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !29) - ret void -} - -define weak void @_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPKwEEEEvv() { -entry: - tail call void @llvm.dbg.func.start(metadata !30) - tail call void @llvm.dbg.stoppoint(i32 63, i32 0, metadata !2) - tail call void @llvm.dbg.region.end(metadata !30) - ret void -} - -declare void @llvm.dbg.func.start(metadata) nounwind readnone - -declare void @llvm.dbg.stoppoint(i32, i32, metadata) nounwind readnone - -declare void @llvm.dbg.region.end(metadata) nounwind readnone - -declare extern_weak i32 @pthread_once(i32*, void ()*) - -declare extern_weak i8* @pthread_getspecific(i32) - -declare extern_weak i32 @pthread_setspecific(i32, i8*) - -declare extern_weak i32 @pthread_create(i64*, %struct.pthread_attr_t*, i8* (i8*)*, i8*) - -declare extern_weak i32 @pthread_cancel(i64) - -declare extern_weak i32 @pthread_mutex_lock(%struct.pthread_mutex_t*) - -declare extern_weak i32 @pthread_mutex_trylock(%struct.pthread_mutex_t*) - -declare extern_weak i32 @pthread_mutex_unlock(%struct.pthread_mutex_t*) - -declare extern_weak i32 @pthread_mutex_init(%struct.pthread_mutex_t*, %"struct.__gnu_cxx::_ConvertibleConcept"*) - -declare extern_weak i32 @pthread_key_create(i32*, void (i8*)*) - -declare extern_weak i32 @pthread_key_delete(i32) - -declare extern_weak i32 @pthread_mutexattr_init(%"struct.__gnu_cxx::_ConvertibleConcept"*) - -declare extern_weak i32 @pthread_mutexattr_settype(%"struct.__gnu_cxx::_ConvertibleConcept"*, i32) - -declare extern_weak i32 @pthread_mutexattr_destroy(%"struct.__gnu_cxx::_ConvertibleConcept"*) - -!0 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__aux_require_boolean_expr", metadata !"__aux_require_boolean_expr", metadata !"_ZN9__gnu_cxx26__aux_require_boolean_exprIbEEvRKT_", metadata !2, i32 239, metadata !3, i1 false, i1 true} -!1 = metadata !{i32 458769, i32 0, i32 4, metadata !"concept-inst.cc", metadata !"/home/buildbot/buildslave/llvm-x86_64-linux-selfhost/llvm-gcc.obj/x86_64-unknown-linux-gnu/libstdc++-v3/src/../../../../llvm-gcc.src/libstdc++-v3/src", metadata !"4.2.1 (Based on Apple Inc. build 5649) (LLVM build)", i1 true, i1 true, metadata !"", i32 0} -!2 = metadata !{i32 458769, i32 0, i32 4, metadata !"boost_concept_check.h", metadata !"/home/buildbot/buildslave/llvm-x86_64-linux-selfhost/llvm-gcc.obj/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits", metadata !"4.2.1 (Based on Apple Inc. build 5649) (LLVM build)", i1 false, i1 true, metadata !"", i32 0} -!3 = metadata !{i32 458773, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0} -!4 = metadata !{null, metadata !5} -!5 = metadata !{i32 458768, metadata !1, metadata !"", metadata !1, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !6} -!6 = metadata !{i32 458790, metadata !1, metadata !"", metadata !1, i32 0, i64 8, i64 8, i64 0, i32 0, metadata !7} -!7 = metadata !{i32 458788, metadata !1, metadata !"bool", metadata !1, i32 0, i64 8, i64 8, i64 0, i32 0, i32 2} -!8 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_ConvertibleConcept >", metadata !"__function_requires<__gnu_cxx::_ConvertibleConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_19_ConvertibleConceptIjjEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!9 = metadata !{i32 458773, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !10, i32 0} -!10 = metadata !{null} -!11 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept >", metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!12 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept >", metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPKcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!13 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept >", metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!14 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept >", metadata !"__function_requires<__gnu_cxx::_InputIteratorConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_21_InputIteratorConceptIPKwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!15 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIPwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!16 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIPcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!17 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIiEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!18 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIlEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!19 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIxEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!20 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"__function_requires<__gnu_cxx::_LessThanComparableConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_26_LessThanComparableConceptIjEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!21 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_OutputIteratorConcept >, char> >", metadata !"__function_requires<__gnu_cxx::_OutputIteratorConcept >, char> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_22_OutputIteratorConceptISt19ostreambuf_iteratorIcSt11char_traitsIcEEcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!22 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_OutputIteratorConcept >, wchar_t> >", metadata !"__function_requires<__gnu_cxx::_OutputIteratorConcept >, wchar_t> >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_22_OutputIteratorConceptISt19ostreambuf_iteratorIwSt11char_traitsIwEEwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!23 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!24 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPKcEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!25 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator, std::allocator > > > >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator, std::allocator > > > >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPKcSsEEEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!26 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator, std::allocator > > > >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator, std::allocator > > > >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPcSsEEEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!27 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator, std::allocator > > > >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator, std::allocator > > > >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPKwSbIwSt11char_traitsIwESaIwEEEEEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!28 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator, std::allocator > > > >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept<__gnu_cxx::__normal_iterator, std::allocator > > > >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptINS_17__normal_iteratorIPwSbIwSt11char_traitsIwESaIwEEEEEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!29 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} -!30 = metadata !{i32 458798, i32 0, metadata !1, metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept >", metadata !"__function_requires<__gnu_cxx::_RandomAccessIteratorConcept >", metadata !"_ZN9__gnu_cxx19__function_requiresINS_28_RandomAccessIteratorConceptIPKwEEEEvv", metadata !2, i32 61, metadata !9, i1 false, i1 true} diff --git a/test/Transforms/GlobalDCE/dg.exp b/test/Transforms/GlobalDCE/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/GlobalDCE/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/GlobalDCE/lit.local.cfg b/test/Transforms/GlobalDCE/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/GlobalDCE/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll index a6803abc5d36..588d5c9a6844 100644 --- a/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll +++ b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll @@ -3,7 +3,7 @@ define double @foo() nounwind { entry: - %tmp1 = volatile load double* @t0.1441, align 8 ; [#uses=2] + %tmp1 = load volatile double* @t0.1441, align 8 ; [#uses=2] %tmp4 = fmul double %tmp1, %tmp1 ; [#uses=1] ret double %tmp4 } diff --git a/test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll b/test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll deleted file mode 100644 index 0e70c49adf14..000000000000 --- a/test/Transforms/GlobalOpt/2008-02-16-NestAttr.ll +++ /dev/null @@ -1,57 +0,0 @@ -; RUN: opt < %s -globalopt -S | grep { nest } | count 1 - %struct.FRAME.nest = type { i32, i32 (i32)* } - %struct.__builtin_trampoline = type { [10 x i8] } -@.str = internal constant [7 x i8] c"%d %d\0A\00" ; <[7 x i8]*> [#uses=1] - -define i32 @process(i32 (i32)* %func) nounwind { -entry: - %tmp2 = tail call i32 %func( i32 1 ) nounwind ; [#uses=1] - ret i32 %tmp2 -} - -define internal fastcc i32 @g.1478(%struct.FRAME.nest* nest %CHAIN.1, i32 %m) nounwind { -entry: - %tmp3 = getelementptr %struct.FRAME.nest* %CHAIN.1, i32 0, i32 0 ; [#uses=1] - %tmp4 = load i32* %tmp3, align 4 ; [#uses=1] - %tmp7 = icmp eq i32 %tmp4, %m ; [#uses=1] - %tmp78 = zext i1 %tmp7 to i32 ; [#uses=1] - ret i32 %tmp78 -} - -define internal i32 @f.1481(%struct.FRAME.nest* nest %CHAIN.2, i32 %m) nounwind { -entry: - %tmp4 = tail call fastcc i32 @g.1478( %struct.FRAME.nest* nest %CHAIN.2, i32 %m ) nounwind ; [#uses=1] - %tmp6 = getelementptr %struct.FRAME.nest* %CHAIN.2, i32 0, i32 0 ; [#uses=1] - %tmp7 = load i32* %tmp6, align 4 ; [#uses=1] - %tmp9 = icmp eq i32 %tmp4, %tmp7 ; [#uses=1] - %tmp910 = zext i1 %tmp9 to i32 ; [#uses=1] - ret i32 %tmp910 -} - -define i32 @nest(i32 %n) nounwind { -entry: - %TRAMP.316 = alloca [10 x i8] ; <[10 x i8]*> [#uses=1] - %FRAME.0 = alloca %struct.FRAME.nest ; <%struct.FRAME.nest*> [#uses=3] - %TRAMP.316.sub = getelementptr [10 x i8]* %TRAMP.316, i32 0, i32 0 ; [#uses=1] - %tmp3 = getelementptr %struct.FRAME.nest* %FRAME.0, i32 0, i32 0 ; [#uses=1] - store i32 %n, i32* %tmp3, align 8 - %FRAME.06 = bitcast %struct.FRAME.nest* %FRAME.0 to i8* ; [#uses=1] - %tramp = call i8* @llvm.init.trampoline( i8* %TRAMP.316.sub, i8* bitcast (i32 (%struct.FRAME.nest*, i32)* @f.1481 to i8*), i8* %FRAME.06 ) ; [#uses=1] - %tmp7 = getelementptr %struct.FRAME.nest* %FRAME.0, i32 0, i32 1 ; [#uses=1] - %tmp89 = bitcast i8* %tramp to i32 (i32)* ; [#uses=2] - store i32 (i32)* %tmp89, i32 (i32)** %tmp7, align 4 - %tmp13 = call i32 @process( i32 (i32)* %tmp89 ) nounwind ; [#uses=1] - ret i32 %tmp13 -} - -declare i8* @llvm.init.trampoline(i8*, i8*, i8*) nounwind - -define i32 @main() nounwind { -entry: - %tmp = tail call i32 @nest( i32 2 ) nounwind ; [#uses=1] - %tmp1 = tail call i32 @nest( i32 1 ) nounwind ; [#uses=1] - %tmp3 = tail call i32 (i8*, ...)* @printf( i8* noalias getelementptr ([7 x i8]* @.str, i32 0, i32 0), i32 %tmp1, i32 %tmp ) nounwind ; [#uses=0] - ret i32 undef -} - -declare i32 @printf(i8*, ...) nounwind diff --git a/test/Transforms/GlobalOpt/atomic.ll b/test/Transforms/GlobalOpt/atomic.ll new file mode 100644 index 000000000000..4c3f4395a0ea --- /dev/null +++ b/test/Transforms/GlobalOpt/atomic.ll @@ -0,0 +1,10 @@ +; RUN: opt -globalopt < %s -S -o - | FileCheck %s + +@GV1 = internal global i64 1 +; CHECK: @GV1 = internal unnamed_addr constant i64 1 + +define void @test1() { +entry: + %0 = load atomic i8* bitcast (i64* @GV1 to i8*) acquire, align 8 + ret void +} diff --git a/test/Transforms/GlobalOpt/constantfold-initializers.ll b/test/Transforms/GlobalOpt/constantfold-initializers.ll index 834bd0012e7a..af8fa324db8c 100644 --- a/test/Transforms/GlobalOpt/constantfold-initializers.ll +++ b/test/Transforms/GlobalOpt/constantfold-initializers.ll @@ -6,3 +6,46 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 ; CHECK: @A = global i1 false @A = global i1 icmp ne (i64 sub nsw (i64 ptrtoint (i8* getelementptr inbounds ([3 x i8]* @.str91250, i64 0, i64 1) to i64), i64 ptrtoint ([3 x i8]* @.str91250 to i64)), i64 1) + +; PR11352 + +@xs = global [2 x i32] zeroinitializer, align 4 +; CHECK: @xs = global [2 x i32] [i32 1, i32 1] + +define internal void @test1() { +entry: + store i32 1, i32* getelementptr inbounds ([2 x i32]* @xs, i64 0, i64 0) + %0 = load i32* getelementptr inbounds ([2 x i32]* @xs, i32 0, i64 0), align 4 + store i32 %0, i32* getelementptr inbounds ([2 x i32]* @xs, i64 0, i64 1) + ret void +} + +; PR12060 + +%closure = type { i32 } + +@f = internal global %closure zeroinitializer, align 4 +@m = global i32 0, align 4 +; CHECK-NOT: @f +; CHECK: @m = global i32 13 + +define internal i32 @test2_helper(%closure* %this, i32 %b) { +entry: + %0 = getelementptr inbounds %closure* %this, i32 0, i32 0 + %1 = load i32* %0, align 4 + %add = add nsw i32 %1, %b + ret i32 %add +} + +define internal void @test2() { +entry: + store i32 4, i32* getelementptr inbounds (%closure* @f, i32 0, i32 0) + %call = call i32 @test2_helper(%closure* @f, i32 9) + store i32 %call, i32* @m, align 4 + ret void +} + +@llvm.global_ctors = appending constant + [2 x { i32, void ()* }] + [{ i32, void ()* } { i32 65535, void ()* @test1 }, + { i32, void ()* } { i32 65535, void ()* @test2 }] diff --git a/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll b/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll index 204f979ed3e1..e3bc473f52ad 100644 --- a/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll +++ b/test/Transforms/GlobalOpt/ctor-list-opt-constexpr.ll @@ -4,20 +4,31 @@ target triple = "x86_64-apple-darwin10.0.0" %0 = type { i32, void ()* } %struct.foo = type { i32* } +%struct.bar = type { i128 } @G = global i32 0, align 4 @H = global i32 0, align 4 @X = global %struct.foo zeroinitializer, align 8 -@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @init }] +@X2 = global %struct.bar zeroinitializer, align 8 +@llvm.global_ctors = appending global [2 x %0] [%0 { i32 65535, void ()* @init1 }, %0 { i32 65535, void ()* @init2 }] ; PR8710 - GlobalOpt shouldn't change the global's initializer to have this ; arbitrary constant expression, the code generator can't handle it. -define internal void @init() { +define internal void @init1() { entry: %tmp = getelementptr inbounds %struct.foo* @X, i32 0, i32 0 store i32* inttoptr (i64 sdiv (i64 ptrtoint (i32* @G to i64), i64 ptrtoint (i32* @H to i64)) to i32*), i32** %tmp, align 8 ret void } - -; CHECK: @init +; CHECK: @init1 ; CHECK: store i32* + +; PR11705 - ptrtoint isn't safe in general in global initializers. +define internal void @init2() { +entry: + %tmp = getelementptr inbounds %struct.bar* @X2, i32 0, i32 0 + store i128 ptrtoint (i32* @G to i128), i128* %tmp, align 16 + ret void +} +; CHECK: @init2 +; CHECK: store i128 diff --git a/test/Transforms/GlobalOpt/cxx-dtor.ll b/test/Transforms/GlobalOpt/cxx-dtor.ll index 22635620baad..7c6ae78d1bc0 100644 --- a/test/Transforms/GlobalOpt/cxx-dtor.ll +++ b/test/Transforms/GlobalOpt/cxx-dtor.ll @@ -2,6 +2,7 @@ %0 = type { i32, void ()* } %struct.A = type { i8 } +%struct.B = type { } @a = global %struct.A zeroinitializer, align 1 @__dso_handle = external global i8* @@ -15,13 +16,14 @@ define internal void @__cxx_global_var_init() nounwind section "__TEXT,__StaticI } define linkonce_odr void @_ZN1AD1Ev(%struct.A* %this) nounwind align 2 { - call void @_ZN1AD2Ev(%struct.A* %this) + %t = bitcast %struct.A* %this to %struct.B* + call void @_ZN1BD1Ev(%struct.B* %t) ret void } declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) -define linkonce_odr void @_ZN1AD2Ev(%struct.A* %this) nounwind align 2 { +define linkonce_odr void @_ZN1BD1Ev(%struct.B* %this) nounwind align 2 { ret void } diff --git a/test/Transforms/GlobalOpt/deadfunction.ll b/test/Transforms/GlobalOpt/deadfunction.ll new file mode 100644 index 000000000000..5e003c63f77d --- /dev/null +++ b/test/Transforms/GlobalOpt/deadfunction.ll @@ -0,0 +1,27 @@ +; RUN: opt < %s -globalopt -S | FileCheck %s + +; CHECK-NOT: test + +declare void @aa() +declare void @bb() + +; Test that we can erase a function which has a blockaddress referring to it +@test.x = internal unnamed_addr constant [3 x i8*] [i8* blockaddress(@test, %a), i8* blockaddress(@test, %b), i8* blockaddress(@test, %c)], align 16 +define internal void @test(i32 %n) nounwind noinline { +entry: + %idxprom = sext i32 %n to i64 + %arrayidx = getelementptr inbounds [3 x i8*]* @test.x, i64 0, i64 %idxprom + %0 = load i8** %arrayidx, align 8 + indirectbr i8* %0, [label %a, label %b, label %c] + +a: + tail call void @aa() nounwind + br label %b + +b: + tail call void @bb() nounwind + br label %c + +c: + ret void +} diff --git a/test/Transforms/GlobalOpt/dg.exp b/test/Transforms/GlobalOpt/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/GlobalOpt/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/GlobalOpt/invariant.ll b/test/Transforms/GlobalOpt/invariant.ll new file mode 100644 index 000000000000..6b9919347890 --- /dev/null +++ b/test/Transforms/GlobalOpt/invariant.ll @@ -0,0 +1,59 @@ +; RUN: opt -globalopt -S -o - < %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" +target triple = "x86_64-unknown-linux-gnu" + +declare {}* @llvm.invariant.start(i64 %size, i8* nocapture %ptr) + +define void @test1(i8* %ptr) { + call {}* @llvm.invariant.start(i64 4, i8* %ptr) + ret void +} + +@object1 = global i32 0 +; CHECK: @object1 = constant i32 -1 +define void @ctor1() { + store i32 -1, i32* @object1 + %A = bitcast i32* @object1 to i8* + call void @test1(i8* %A) + ret void +} + + +@object2 = global i32 0 +; CHECK: @object2 = global i32 0 +define void @ctor2() { + store i32 -1, i32* @object2 + %A = bitcast i32* @object2 to i8* + %B = call {}* @llvm.invariant.start(i64 4, i8* %A) + %C = bitcast {}* %B to i8* + ret void +} + + +@object3 = global i32 0 +; CHECK: @object3 = global i32 -1 +define void @ctor3() { + store i32 -1, i32* @object3 + %A = bitcast i32* @object3 to i8* + call {}* @llvm.invariant.start(i64 3, i8* %A) + ret void +} + + +@object4 = global i32 0 +; CHECK: @object4 = global i32 -1 +define void @ctor4() { + store i32 -1, i32* @object4 + %A = bitcast i32* @object4 to i8* + call {}* @llvm.invariant.start(i64 -1, i8* %A) + ret void +} + + +@llvm.global_ctors = appending constant + [4 x { i32, void ()* }] + [ { i32, void ()* } { i32 65535, void ()* @ctor1 }, + { i32, void ()* } { i32 65535, void ()* @ctor2 }, + { i32, void ()* } { i32 65535, void ()* @ctor3 }, + { i32, void ()* } { i32 65535, void ()* @ctor4 } ] diff --git a/test/Transforms/GlobalOpt/invoke.ll b/test/Transforms/GlobalOpt/invoke.ll new file mode 100644 index 000000000000..c1f499c38a3c --- /dev/null +++ b/test/Transforms/GlobalOpt/invoke.ll @@ -0,0 +1,27 @@ +; RUN: opt -S -globalopt < %s | FileCheck %s +; rdar://11022897 + +; Globalopt should be able to evaluate an invoke. +; CHECK: @tmp = global i32 1 + +@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }] +@tmp = global i32 0 + +define i32 @one() { + ret i32 1 +} + +define void @_GLOBAL__I_a() { +bb: + %tmp1 = invoke i32 @one() + to label %bb2 unwind label %bb4 + +bb2: ; preds = %bb + store i32 %tmp1, i32* @tmp + ret void + +bb4: ; preds = %bb + %tmp5 = landingpad { i8*, i32 } personality i8* undef + filter [0 x i8*] zeroinitializer + unreachable +} diff --git a/test/Transforms/GlobalOpt/lit.local.cfg b/test/Transforms/GlobalOpt/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/GlobalOpt/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/GlobalOpt/zeroinitializer-gep-load.ll b/test/Transforms/GlobalOpt/zeroinitializer-gep-load.ll new file mode 100644 index 000000000000..d613601e8d78 --- /dev/null +++ b/test/Transforms/GlobalOpt/zeroinitializer-gep-load.ll @@ -0,0 +1,11 @@ +; RUN: opt < %s -S -globalopt | FileCheck %s + +@zero = internal global [10 x i32] zeroinitializer + +define i32 @test1(i64 %idx) nounwind { + %arrayidx = getelementptr inbounds [10 x i32]* @zero, i64 0, i64 %idx + %l = load i32* %arrayidx + ret i32 %l +; CHECK: @test1 +; CHECK: ret i32 0 +} diff --git a/test/Transforms/IPConstantProp/dangling-block-address.ll b/test/Transforms/IPConstantProp/dangling-block-address.ll index 0489dfa796f3..bb101333f801 100644 --- a/test/Transforms/IPConstantProp/dangling-block-address.ll +++ b/test/Transforms/IPConstantProp/dangling-block-address.ll @@ -12,7 +12,7 @@ define void @foo(i32 %x) nounwind readnone { entry: %b = alloca i32, align 4 ; [#uses=1] - volatile store i32 -1, i32* %b + store volatile i32 -1, i32* %b ret void } diff --git a/test/Transforms/IPConstantProp/dg.exp b/test/Transforms/IPConstantProp/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/IPConstantProp/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/IPConstantProp/lit.local.cfg b/test/Transforms/IPConstantProp/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/IPConstantProp/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll b/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll index 77354f75106a..af9f1b38f1a9 100644 --- a/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll +++ b/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -S | FileCheck %s ; Test WidenIV::GetExtendedOperandRecurrence. ; add219 should be extended to i64 because it is nsw, even though its ; sext cannot be hoisted outside the loop. @@ -19,7 +19,7 @@ for.body153: ; preds = %for.body153, %for.b ; CHECK: add nsw i64 %indvars.iv, 1 for.body170: ; preds = %for.body170, %for.body153 - %i2.19 = phi i32 [ %add249, %for.body170 ], [ undef, %for.body153 ] + %i2.19 = phi i32 [ %add249, %for.body170 ], [ 0, %for.body153 ] %add219 = add nsw i32 %i2.19, 1 %idxprom220 = sext i32 %add219 to i64 %add249 = add nsw i32 %i2.19, %shl132 diff --git a/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll b/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll new file mode 100644 index 000000000000..76c90e0cddd9 --- /dev/null +++ b/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll @@ -0,0 +1,59 @@ +; RUN: opt < %s -indvars -S | FileCheck %s +; rdar://10359193: assert "IndVar type must match IVInit type" + +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32" +target triple = "thumbv7-apple-darwin" + +; CHECK: @test +; CHECK: if.end.i126: +; CHECK: %exitcond = icmp ne i8* %incdec.ptr.i, getelementptr (i8* null, i32 undef) +define void @test() nounwind { +entry: + br label %while.cond + +while.cond: + br i1 undef, label %while.end, label %while.body + +while.body: ; preds = %while.cond + br i1 undef, label %if.then165, label %while.cond + +if.then165: ; preds = %while.body + br i1 undef, label %while.cond, label %for.body.lr.ph.i81 + +for.body.lr.ph.i81: ; preds = %if.then165 + br label %for.body.i86 + +for.body.i86: ; preds = %for.end.i129, %for.body.lr.ph.i81 + %cmp196.i = icmp ult i32 0, undef + br i1 %cmp196.i, label %for.body21.lr.ph.i, label %for.end.i129 + +for.body21.lr.ph.i: ; preds = %for.body.i86 + br label %for.body21.i + +for.body21.i: + %destYPixelPtr.010.i = phi i8* [ null, %for.body21.lr.ph.i ], [ %incdec.ptr.i, %if.end.i126 ] + %x.09.i = phi i32 [ 0, %for.body21.lr.ph.i ], [ %inc.i125, %if.end.i126 ] + br i1 undef, label %if.end.i126, label %if.else.i124 + +if.else.i124: ; preds = %for.body21.i + store i8 undef, i8* %destYPixelPtr.010.i, align 1 + br label %if.end.i126 + +if.end.i126: ; preds = %if.else.i124, %for.body21.i + %incdec.ptr.i = getelementptr inbounds i8* %destYPixelPtr.010.i, i32 1 + %inc.i125 = add i32 %x.09.i, 1 + %cmp19.i = icmp ult i32 %inc.i125, undef + br i1 %cmp19.i, label %for.body21.i, label %for.end.i129 + +for.end.i129: ; preds = %if.end.i126, %for.body.i86 + br i1 undef, label %for.body.i86, label %while.cond + +while.end: ; preds = %while.cond + br label %bail + +bail: ; preds = %while.end, %lor.lhs.false44, %lor.lhs.false41, %if.end29, %if.end + unreachable + +return: ; preds = %lor.lhs.false20, %lor.lhs.false12, %lor.lhs.false, %entry + ret void +} diff --git a/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll b/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll new file mode 100644 index 000000000000..c0c508f02ecd --- /dev/null +++ b/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll @@ -0,0 +1,140 @@ +; RUN: opt < %s -indvars -S "-default-data-layout=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" | FileCheck %s +; RUN: opt < %s -indvars -S "-default-data-layout=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-n8:16:32" | FileCheck %s +; +; PR11279: Assertion !IVLimit->getType()->isPointerTy() +; +; Test LinearFunctionTestReplace of a pointer-type loop counter. Note +; that BECount may or may not be a pointer type. A pointer type +; BECount doesn't really make sense, but that's what falls out of +; SCEV. Since it's an i8*, it has unit stride so we never adjust the +; SCEV expression in a way that would convert it to an integer type. + +; CHECK: @testnullptrptr +; CHECK: loop: +; CHECK: icmp ne +define i8 @testnullptrptr(i8* %buf, i8* %end) nounwind { + br label %loopguard + +loopguard: + %guard = icmp ult i8* null, %end + br i1 %guard, label %preheader, label %exit + +preheader: + br label %loop + +loop: + %p.01.us.us = phi i8* [ null, %preheader ], [ %gep, %loop ] + %s = phi i8 [0, %preheader], [%snext, %loop] + %gep = getelementptr inbounds i8* %p.01.us.us, i64 1 + %snext = load i8* %gep + %cmp = icmp ult i8* %gep, %end + br i1 %cmp, label %loop, label %exit + +exit: + ret i8 %snext +} + +; CHECK: @testptrptr +; CHECK: loop: +; CHECK: icmp ne +define i8 @testptrptr(i8* %buf, i8* %end) nounwind { + br label %loopguard + +loopguard: + %guard = icmp ult i8* %buf, %end + br i1 %guard, label %preheader, label %exit + +preheader: + br label %loop + +loop: + %p.01.us.us = phi i8* [ %buf, %preheader ], [ %gep, %loop ] + %s = phi i8 [0, %preheader], [%snext, %loop] + %gep = getelementptr inbounds i8* %p.01.us.us, i64 1 + %snext = load i8* %gep + %cmp = icmp ult i8* %gep, %end + br i1 %cmp, label %loop, label %exit + +exit: + ret i8 %snext +} + +; CHECK: @testnullptrint +; CHECK: loop: +; CHECK: icmp ne +define i8 @testnullptrint(i8* %buf, i8* %end) nounwind { + br label %loopguard + +loopguard: + %bi = ptrtoint i8* %buf to i32 + %ei = ptrtoint i8* %end to i32 + %cnt = sub i32 %ei, %bi + %guard = icmp ult i32 0, %cnt + br i1 %guard, label %preheader, label %exit + +preheader: + br label %loop + +loop: + %p.01.us.us = phi i8* [ null, %preheader ], [ %gep, %loop ] + %iv = phi i32 [ 0, %preheader ], [ %ivnext, %loop ] + %s = phi i8 [0, %preheader], [%snext, %loop] + %gep = getelementptr inbounds i8* %p.01.us.us, i64 1 + %snext = load i8* %gep + %ivnext = add i32 %iv, 1 + %cmp = icmp ult i32 %ivnext, %cnt + br i1 %cmp, label %loop, label %exit + +exit: + ret i8 %snext +} + +; CHECK: @testptrint +; CHECK: loop: +; CHECK: icmp ne +define i8 @testptrint(i8* %buf, i8* %end) nounwind { + br label %loopguard + +loopguard: + %bi = ptrtoint i8* %buf to i32 + %ei = ptrtoint i8* %end to i32 + %cnt = sub i32 %ei, %bi + %guard = icmp ult i32 %bi, %cnt + br i1 %guard, label %preheader, label %exit + +preheader: + br label %loop + +loop: + %p.01.us.us = phi i8* [ %buf, %preheader ], [ %gep, %loop ] + %iv = phi i32 [ %bi, %preheader ], [ %ivnext, %loop ] + %s = phi i8 [0, %preheader], [%snext, %loop] + %gep = getelementptr inbounds i8* %p.01.us.us, i64 1 + %snext = load i8* %gep + %ivnext = add i32 %iv, 1 + %cmp = icmp ult i32 %ivnext, %cnt + br i1 %cmp, label %loop, label %exit + +exit: + ret i8 %snext +} + +; IV and BECount have two different pointer types here. +define void @testnullptr([512 x i8]* %base) nounwind { +entry: + %add.ptr1603 = getelementptr [512 x i8]* %base, i64 0, i64 512 + br label %preheader + +preheader: + %cmp1604192 = icmp ult i8* undef, %add.ptr1603 + br i1 %cmp1604192, label %for.body, label %for.end1609 + +for.body: + %r.17193 = phi i8* [ %incdec.ptr1608, %for.body ], [ null, %preheader ] + %incdec.ptr1608 = getelementptr i8* %r.17193, i64 1 + %cmp1604 = icmp ult i8* %incdec.ptr1608, %add.ptr1603 + br i1 %cmp1604, label %for.body, label %for.end1609 + +for.end1609: + unreachable +} diff --git a/test/Transforms/IndVarSimplify/2011-11-15-multiexit.ll b/test/Transforms/IndVarSimplify/2011-11-15-multiexit.ll new file mode 100644 index 000000000000..c74d04e6a5d8 --- /dev/null +++ b/test/Transforms/IndVarSimplify/2011-11-15-multiexit.ll @@ -0,0 +1,40 @@ +; RUN: opt < %s -indvars -S | FileCheck %s +; +; Prior to the fix for PR11375, indvars would replace %firstIV with a +; loop-invariant gep computed in the preheader. This was incorrect +; because it was based on the minimum "ExitNotTaken" count. If the +; final loop test is skipped (odd number of elements) then the early +; exit would be taken and the loop invariant value would be incorrect. + +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" +target triple = "x86_64-apple-darwin" + +; CHECK: if.end: +; CHECK: phi i32* [ %first.lcssa, %early.exit ] +define i32 @test(i32* %first, i32* %last) uwtable ssp { +entry: + br i1 undef, label %if.end, label %if.then + +if.then: ; preds = %entry + br i1 undef, label %if.end, label %do.body + +do.body: ; preds = %if.else, %if.then + %firstIV = phi i32* [ %incdec.ptr2, %if.else ], [ %first, %if.then ] + %incdec.ptr1 = getelementptr inbounds i32* %firstIV, i64 1 + %cmp1 = icmp eq i32* %incdec.ptr1, %last + br i1 %cmp1, label %early.exit, label %if.else + +if.else: ; preds = %do.body + %incdec.ptr2 = getelementptr inbounds i32* %firstIV, i64 2 + %cmp2 = icmp eq i32* %incdec.ptr2, %last + br i1 %cmp2, label %if.end, label %do.body + +early.exit: + %first.lcssa = phi i32* [ %firstIV, %do.body ] + br label %if.end + +if.end: + %tmp = phi i32* [ %first.lcssa, %early.exit ], [ %first, %if.then ], [ %first, %entry ], [ undef, %if.else ] + %val = load i32* %tmp + ret i32 %val +} diff --git a/test/Transforms/IndVarSimplify/2011-11-17-selfphi.ll b/test/Transforms/IndVarSimplify/2011-11-17-selfphi.ll new file mode 100644 index 000000000000..ccf259597e30 --- /dev/null +++ b/test/Transforms/IndVarSimplify/2011-11-17-selfphi.ll @@ -0,0 +1,29 @@ +; RUN: opt < %s -indvars -S | FileCheck %s +; PR11350: Check that SimplifyIndvar handles a cycle of useless self-phis. + +; CHECK: @test +; CHECK-NOT: lcssa = phi +define void @test() nounwind { +entry: + br label %for.cond.preheader + +for.cond.preheader: ; preds = %entry + br label %for.cond.outer + +for.cond.outer: ; preds = %for.cond.preheader, %for.end + %p_41.addr.0.ph = phi i32 [ %p_41.addr.1.lcssa, %for.end ], [ 1, %for.cond.preheader ] + br label %for.cond + +for.cond: + br i1 true, label %for.end, label %for.ph + +for.ph: ; preds = %for.cond4.preheader + br label %for.end + +for.end: + %p_41.addr.1.lcssa = phi i32 [ undef, %for.ph ], [ %p_41.addr.0.ph, %for.cond ] + %p_68.lobit.i = lshr i32 %p_41.addr.1.lcssa, 31 + %cmp7 = icmp eq i32 %p_41.addr.1.lcssa, 0 + %conv8 = zext i1 %cmp7 to i32 + br label %for.cond.outer +} diff --git a/test/Transforms/IndVarSimplify/ada-loops.ll b/test/Transforms/IndVarSimplify/ada-loops.ll index 154de6fea4b6..c0932982ee5e 100644 --- a/test/Transforms/IndVarSimplify/ada-loops.ll +++ b/test/Transforms/IndVarSimplify/ada-loops.ll @@ -1,5 +1,4 @@ ; RUN: opt < %s -indvars -S | FileCheck %s -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s ; ; PR1301 diff --git a/test/Transforms/IndVarSimplify/addrec-gep.ll b/test/Transforms/IndVarSimplify/addrec-gep.ll deleted file mode 100644 index b62d093960c3..000000000000 --- a/test/Transforms/IndVarSimplify/addrec-gep.ll +++ /dev/null @@ -1,78 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK: getelementptr -; CHECK: mul {{.*}}, 37 -; CHECK: add {{.*}}, 5203 -; CHECK-NOT: cast - -; This test tests several things. The load and store should use the -; same address instead of having it computed twice, and SCEVExpander should -; be able to reconstruct the full getelementptr, despite it having a few -; obstacles set in its way. - -target datalayout = "e-p:64:64:64-n32:64" - -define void @foo(i64 %n, i64 %m, i64 %o, i64 %q, double* nocapture %p) nounwind { -entry: - %tmp = icmp sgt i64 %n, 0 ; [#uses=1] - br i1 %tmp, label %bb.nph3, label %return - -bb.nph: ; preds = %bb2.preheader - %tmp1 = mul i64 %tmp16, %i.02 ; [#uses=1] - %tmp2 = mul i64 %tmp19, %i.02 ; [#uses=1] - br label %bb1 - -bb1: ; preds = %bb2, %bb.nph - %j.01 = phi i64 [ %tmp9, %bb2 ], [ 0, %bb.nph ] ; [#uses=3] - %tmp3 = add i64 %j.01, %tmp1 ; [#uses=1] - %tmp4 = add i64 %j.01, %tmp2 ; [#uses=1] - %z0 = add i64 %tmp3, 5203 - %tmp5 = getelementptr double* %p, i64 %z0 ; [#uses=1] - %tmp6 = load double* %tmp5, align 8 ; [#uses=1] - %tmp7 = fdiv double %tmp6, 2.100000e+00 ; [#uses=1] - %z1 = add i64 %tmp4, 5203 - %tmp8 = getelementptr double* %p, i64 %z1 ; [#uses=1] - store double %tmp7, double* %tmp8, align 8 - %tmp9 = add i64 %j.01, 1 ; [#uses=2] - br label %bb2 - -bb2: ; preds = %bb1 - %tmp10 = icmp slt i64 %tmp9, %m ; [#uses=1] - br i1 %tmp10, label %bb1, label %bb2.bb3_crit_edge - -bb2.bb3_crit_edge: ; preds = %bb2 - br label %bb3 - -bb3: ; preds = %bb2.preheader, %bb2.bb3_crit_edge - %tmp11 = add i64 %i.02, 1 ; [#uses=2] - br label %bb4 - -bb4: ; preds = %bb3 - %tmp12 = icmp slt i64 %tmp11, %n ; [#uses=1] - br i1 %tmp12, label %bb2.preheader, label %bb4.return_crit_edge - -bb4.return_crit_edge: ; preds = %bb4 - br label %bb4.return_crit_edge.split - -bb4.return_crit_edge.split: ; preds = %bb.nph3, %bb4.return_crit_edge - br label %return - -bb.nph3: ; preds = %entry - %tmp13 = icmp sgt i64 %m, 0 ; [#uses=1] - %tmp14 = mul i64 %n, 37 ; [#uses=1] - %tmp15 = mul i64 %tmp14, %o ; [#uses=1] - %tmp16 = mul i64 %tmp15, %q ; [#uses=1] - %tmp17 = mul i64 %n, 37 ; [#uses=1] - %tmp18 = mul i64 %tmp17, %o ; [#uses=1] - %tmp19 = mul i64 %tmp18, %q ; [#uses=1] - br i1 %tmp13, label %bb.nph3.split, label %bb4.return_crit_edge.split - -bb.nph3.split: ; preds = %bb.nph3 - br label %bb2.preheader - -bb2.preheader: ; preds = %bb.nph3.split, %bb4 - %i.02 = phi i64 [ %tmp11, %bb4 ], [ 0, %bb.nph3.split ] ; [#uses=3] - br i1 true, label %bb.nph, label %bb3 - -return: ; preds = %bb4.return_crit_edge.split, %entry - ret void -} diff --git a/test/Transforms/IndVarSimplify/avoid-i0.ll b/test/Transforms/IndVarSimplify/avoid-i0.ll index 59661fa2e88d..22f2e4b718c2 100644 --- a/test/Transforms/IndVarSimplify/avoid-i0.ll +++ b/test/Transforms/IndVarSimplify/avoid-i0.ll @@ -90,7 +90,7 @@ entry: br label %bb4 bb: ; preds = %bb4 - %0 = volatile load i32* @x, align 4 ; [#uses=1] + %0 = load volatile i32* @x, align 4 ; [#uses=1] store i32 %0, i32* %vol.0, align 4 store i32 0, i32* %l_52, align 4 br label %bb2 diff --git a/test/Transforms/IndVarSimplify/complex-scev.ll b/test/Transforms/IndVarSimplify/complex-scev.ll deleted file mode 100644 index 395377e3a48e..000000000000 --- a/test/Transforms/IndVarSimplify/complex-scev.ll +++ /dev/null @@ -1,31 +0,0 @@ -; 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: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK: phi -; CHECK-NOT: phi - -define void @foo() { -entry: - br label %bb6 - -bb6: ; preds = %cond_true, %entry - %j.0 = phi i32 [ 1, %entry ], [ %tmp5, %cond_true ] ; [#uses=3] - %i.0 = phi i32 [ 0, %entry ], [ %j.0, %cond_true ] ; [#uses=1] - %tmp7 = call i32 (...)* @foo2( ) ; [#uses=1] - %tmp = icmp ne i32 %tmp7, 0 ; [#uses=1] - br i1 %tmp, label %cond_true, label %return - -cond_true: ; preds = %bb6 - %tmp2 = call i32 (...)* @bar( i32 %i.0, i32 %j.0 ) ; [#uses=0] - %tmp5 = add i32 %j.0, 1 ; [#uses=1] - br label %bb6 - -return: ; preds = %bb6 - ret void -} - -declare i32 @bar(...) - -declare i32 @foo2(...) - diff --git a/test/Transforms/IndVarSimplify/dg.exp b/test/Transforms/IndVarSimplify/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/IndVarSimplify/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/IndVarSimplify/elim-extend.ll b/test/Transforms/IndVarSimplify/elim-extend.ll index 43c162fed7f1..ad5679f3e7a4 100644 --- a/test/Transforms/IndVarSimplify/elim-extend.ll +++ b/test/Transforms/IndVarSimplify/elim-extend.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -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" diff --git a/test/Transforms/IndVarSimplify/gep-with-mul-base.ll b/test/Transforms/IndVarSimplify/gep-with-mul-base.ll deleted file mode 100644 index 7e1e2a31768c..000000000000 --- a/test/Transforms/IndVarSimplify/gep-with-mul-base.ll +++ /dev/null @@ -1,68 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK: define void @foo -; CHECK: mul -; CHECK: mul -; CHECK: mul -; CHECK: add -; CHECK: sub -; CHECK: define void @bar -; CHECK: mul -; CHECK: mul -; CHECK: mul -; CHECK: add -; CHECK: sub - -define void @foo(i64 %n, i64 %m, i64 %o, double* nocapture %p) nounwind { -entry: - %tmp = icmp sgt i64 %n, 0 ; [#uses=1] - br i1 %tmp, label %bb.nph, label %return - -bb.nph: ; preds = %entry - %tmp1 = mul i64 %n, 37 ; [#uses=1] - %tmp2 = mul i64 %tmp1, %m ; [#uses=1] - %tmp3 = mul i64 %tmp2, %o ; [#uses=1] - br label %bb - -bb: ; preds = %bb, %bb.nph - %i.01 = phi i64 [ %tmp3, %bb.nph ], [ %tmp13, %bb ] ; [#uses=3] - %tmp9 = getelementptr double* %p, i64 %i.01 ; [#uses=1] - %tmp10 = load double* %tmp9, align 8 ; [#uses=1] - %tmp11 = fdiv double %tmp10, 2.100000e+00 ; [#uses=1] - store double %tmp11, double* %tmp9, align 8 - %tmp13 = add i64 %i.01, 1 ; [#uses=2] - %tmp14 = icmp slt i64 %tmp13, %n ; [#uses=1] - br i1 %tmp14, label %bb, label %return.loopexit - -return.loopexit: ; preds = %bb - br label %return - -return: ; preds = %return.loopexit, %entry - ret void -} -define void @bar(i64 %n, i64 %m, i64 %o, i64 %q, double* nocapture %p) nounwind { -entry: - %tmp = icmp sgt i64 %n, 0 ; [#uses=1] - br i1 %tmp, label %bb.nph, label %return - -bb.nph: ; preds = %entry - %tmp1 = mul i64 %n, %q ; [#uses=1] - %tmp2 = mul i64 %tmp1, %m ; [#uses=1] - %tmp3 = mul i64 %tmp2, %o ; [#uses=1] - br label %bb - -bb: ; preds = %bb, %bb.nph - %i.01 = phi i64 [ %tmp3, %bb.nph ], [ %tmp13, %bb ] ; [#uses=3] - %tmp9 = getelementptr double* %p, i64 %i.01 ; [#uses=1] - %tmp10 = load double* %tmp9, align 8 ; [#uses=1] - %tmp11 = fdiv double %tmp10, 2.100000e+00 ; [#uses=1] - store double %tmp11, double* %tmp9, align 8 - %tmp13 = add i64 %i.01, 1 ; [#uses=2] - %tmp14 = icmp slt i64 %tmp13, %n ; [#uses=1] - br i1 %tmp14, label %bb, label %return.loopexit - -return.loopexit: ; preds = %bb - br label %return - -return: ; preds = %return.loopexit, %entry - ret void -} diff --git a/test/Transforms/IndVarSimplify/iv-fold.ll b/test/Transforms/IndVarSimplify/iv-fold.ll index 2e191184225c..e0b05cdb31f5 100644 --- a/test/Transforms/IndVarSimplify/iv-fold.ll +++ b/test/Transforms/IndVarSimplify/iv-fold.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -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-n32:64" diff --git a/test/Transforms/IndVarSimplify/iv-zext.ll b/test/Transforms/IndVarSimplify/iv-zext.ll index 646e6c00ce6f..2e0f70ce461a 100644 --- a/test/Transforms/IndVarSimplify/iv-zext.ll +++ b/test/Transforms/IndVarSimplify/iv-zext.ll @@ -1,5 +1,4 @@ ; RUN: opt < %s -indvars -S | FileCheck %s -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s ; CHECK-NOT: and ; CHECK-NOT: zext diff --git a/test/Transforms/IndVarSimplify/lftr-reuse.ll b/test/Transforms/IndVarSimplify/lftr-reuse.ll index 490eee9c221d..9abfe13407fc 100644 --- a/test/Transforms/IndVarSimplify/lftr-reuse.ll +++ b/test/Transforms/IndVarSimplify/lftr-reuse.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -S | FileCheck %s ; ; Make sure that indvars can perform LFTR without a canonical IV. diff --git a/test/Transforms/IndVarSimplify/lit.local.cfg b/test/Transforms/IndVarSimplify/lit.local.cfg new file mode 100644 index 000000000000..19eebc0ac7ac --- /dev/null +++ b/test/Transforms/IndVarSimplify/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll', '.c', '.cpp'] diff --git a/test/Transforms/IndVarSimplify/loop_evaluate10.ll b/test/Transforms/IndVarSimplify/loop_evaluate10.ll index 269478a5ed03..c3619f640b33 100644 --- a/test/Transforms/IndVarSimplify/loop_evaluate10.ll +++ b/test/Transforms/IndVarSimplify/loop_evaluate10.ll @@ -1,8 +1,14 @@ ; RUN: opt < %s -indvars -S \ ; RUN: | grep {%b.1 = phi i32 \\\[ 2, %bb \\\], \\\[ 1, %bb2 \\\]} - +; ; This loop has multiple exits, and the value of %b1 depends on which ; exit is taken. Indvars should correctly compute the exit values. +; +; XFAIL: * +; Indvars does not currently replace loop invariant values unless all +; loop exits have the same exit value. We could handle some cases, +; such as this, by making getSCEVAtScope() sensitive to a particular +; loop exit. See PR11388. 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" target triple = "x86_64-pc-linux-gnu" diff --git a/test/Transforms/IndVarSimplify/loop_evaluate9.ll b/test/Transforms/IndVarSimplify/loop_evaluate9.ll index 8184a73f89eb..9f3bcaf21bed 100644 --- a/test/Transforms/IndVarSimplify/loop_evaluate9.ll +++ b/test/Transforms/IndVarSimplify/loop_evaluate9.ll @@ -2,8 +2,13 @@ ; RUN: grep {\[%\]tmp7 = icmp eq i8 -28, -28} %t ; RUN: grep {\[%\]tmp8 = icmp eq i8 63, 63} %t ; PR4477 - ; Indvars should compute the exit values in loop. +; +; XFAIL: * +; Indvars does not currently replace loop invariant values unless all +; loop exits have the same exit value. We could handle some cases, +; such as this, by making getSCEVAtScope() sensitive to a particular +; loop exit. See PR11388. 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:32:32" target triple = "i386-pc-linux-gnu" diff --git a/test/Transforms/IndVarSimplify/no-iv-rewrite.ll b/test/Transforms/IndVarSimplify/no-iv-rewrite.ll index 9c2abd0f31c7..bfdd000e38eb 100644 --- a/test/Transforms/IndVarSimplify/no-iv-rewrite.ll +++ b/test/Transforms/IndVarSimplify/no-iv-rewrite.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s +; RUN: opt < %s -indvars -S | FileCheck %s ; ; Make sure that indvars isn't inserting canonical IVs. ; This is kinda hard to do until linear function test replacement is removed. @@ -333,9 +333,9 @@ entry: ; CHECK: loop: ; CHECK: phi %structIF* -; CHECK: phi i32* -; CHECK: getelementptr inbounds +; CHECK-NOT: phi ; CHECK: getelementptr inbounds +; CHECK-NOT: getelementptr ; CHECK: exit: loop: %ptr.iv = phi %structIF* [ %ptr.inc, %latch ], [ %base, %entry ] diff --git a/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll b/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll deleted file mode 100644 index 251d34ec383a..000000000000 --- a/test/Transforms/IndVarSimplify/preserve-gep-loop-variant.ll +++ /dev/null @@ -1,42 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK-NOT: {{inttoptr|ptrtoint}} -; CHECK: scevgep -; CHECK-NOT: {{inttoptr|ptrtoint}} -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n32:64" - -; Indvars shouldn't need inttoptr/ptrtoint to expand an address here. - -define void @foo(i8* %p) nounwind { -entry: - br i1 true, label %bb.nph, label %for.end - -for.cond: - %phitmp = icmp slt i64 %inc, 20 - br i1 %phitmp, label %for.body, label %for.cond.for.end_crit_edge - -for.cond.for.end_crit_edge: - br label %for.end - -bb.nph: - br label %for.body - -for.body: - %storemerge1 = phi i64 [ %inc, %for.cond ], [ 0, %bb.nph ] - %call = tail call i64 @bar() nounwind - %call2 = tail call i64 @car() nounwind - %conv = trunc i64 %call2 to i8 - %conv3 = sext i8 %conv to i64 - %add = add nsw i64 %call, %storemerge1 - %add4 = add nsw i64 %add, %conv3 - %arrayidx = getelementptr inbounds i8* %p, i64 %add4 - store i8 0, i8* %arrayidx - %inc = add nsw i64 %storemerge1, 1 - br label %for.cond - -for.end: - ret void -} - -declare i64 @bar() - -declare i64 @car() diff --git a/test/Transforms/IndVarSimplify/preserve-gep-nested.ll b/test/Transforms/IndVarSimplify/preserve-gep-nested.ll deleted file mode 100644 index cdcaaa0c9254..000000000000 --- a/test/Transforms/IndVarSimplify/preserve-gep-nested.ll +++ /dev/null @@ -1,76 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; No explicit integer multiplications! -; No i8* arithmetic or pointer casting anywhere! -; CHECK-NOT: = {{= mul|i8\*|bitcast|inttoptr|ptrtoint}} -; Exactly one getelementptr for each load+store. -; Each getelementptr using %struct.Q* %s as a base and not i8*. -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK: getelementptr %struct.Q* %s, -; CHECK-NOT: = {{= mul|i8\*|bitcast|inttoptr|ptrtoint}} - -; FIXME: This test should pass with or without TargetData. Until opt -; supports running tests without targetdata, just hardware this in. -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-n32:64" - -%struct.Q = type { [10 x %struct.N] } -%struct.N = type { %struct.S } -%struct.S = type { [100 x double], [100 x double] } - -define void @foo(%struct.Q* %s, i64 %n) nounwind { -entry: - br label %bb1 - -bb1: - %i = phi i64 [ 2, %entry ], [ %i.next, %bb ] - %j = phi i64 [ 0, %entry ], [ %j.next, %bb ] - %t5 = icmp slt i64 %i, %n - br i1 %t5, label %bb, label %return - -bb: - %t0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %i - %t1 = load double* %t0, align 8 - %t2 = fmul double %t1, 3.200000e+00 - %t3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %i - store double %t2, double* %t3, align 8 - - %s0 = getelementptr inbounds %struct.Q* %s, i64 13, i32 0, i64 7, i32 0, i32 1, i64 %i - %s1 = load double* %s0, align 8 - %s2 = fmul double %s1, 3.200000e+00 - %s3 = getelementptr inbounds %struct.Q* %s, i64 13, i32 0, i64 7, i32 0, i32 1, i64 %i - store double %s2, double* %s3, align 8 - - %u0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 7, i32 0, i32 1, i64 %j - %u1 = load double* %u0, align 8 - %u2 = fmul double %u1, 3.200000e+00 - %u3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 7, i32 0, i32 1, i64 %j - store double %u2, double* %u3, align 8 - - %v0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 1, i64 %i - %v1 = load double* %v0, align 8 - %v2 = fmul double %v1, 3.200000e+00 - %v3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 1, i64 %i - store double %v2, double* %v3, align 8 - - %w0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %j - %w1 = load double* %w0, align 8 - %w2 = fmul double %w1, 3.200000e+00 - %w3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 0, i32 0, i32 0, i64 %j - store double %w2, double* %w3, align 8 - - %x0 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 3, i32 0, i32 0, i64 %i - %x1 = load double* %x0, align 8 - %x2 = fmul double %x1, 3.200000e+00 - %x3 = getelementptr inbounds %struct.Q* %s, i64 0, i32 0, i64 3, i32 0, i32 0, i64 %i - store double %x2, double* %x3, align 8 - - %i.next = add i64 %i, 1 - %j.next = add i64 %j, 1 - br label %bb1 - -return: - ret void -} diff --git a/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll b/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll deleted file mode 100644 index 2f3100fcafbd..000000000000 --- a/test/Transforms/IndVarSimplify/preserve-gep-remainder.ll +++ /dev/null @@ -1,20 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK: %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 2, i64 %0, i64 1 -target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128-n32:64" - -; Indvars shouldn't expand this to -; %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %tmp, i64 19 -; or something. That's valid, but more obscure. - -define void @foo([3 x [3 x double]]* noalias %p) nounwind { -entry: - br label %loop - -loop: - %i = phi i64 [ 0, %entry ], [ %i.next, %loop ] - %ip = add i64 %i, 1 - %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 2, i64 %ip, i64 1 - volatile store double 0.0, double* %p.2.ip.1 - %i.next = add i64 %i, 1 - br label %loop -} diff --git a/test/Transforms/IndVarSimplify/preserve-gep.ll b/test/Transforms/IndVarSimplify/preserve-gep.ll deleted file mode 100644 index fec8a2895988..000000000000 --- a/test/Transforms/IndVarSimplify/preserve-gep.ll +++ /dev/null @@ -1,39 +0,0 @@ -; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s -; CHECK-NOT: {{ptrtoint|inttoptr}} -; CHECK: getelementptr -; CHECK-NOT: {{ptrtoint|inttoptr|getelementptr}} - -; Indvars shouldn't leave getelementptrs expanded out as -; inttoptr+ptrtoint in its output in common cases. - -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-n32:64" -target triple = "x86_64-unknown-linux-gnu" - %struct.Foo = type { i32, i32, [10 x i32], i32 } - -define void @me(%struct.Foo* nocapture %Bar) nounwind { -entry: - br i1 false, label %return, label %bb.nph - -bb.nph: ; preds = %entry - br label %bb - -bb: ; preds = %bb1, %bb.nph - %i.01 = phi i64 [ %4, %bb1 ], [ 0, %bb.nph ] ; [#uses=3] - %0 = getelementptr %struct.Foo* %Bar, i64 %i.01, i32 2, i64 3 ; [#uses=1] - %1 = load i32* %0, align 4 ; [#uses=1] - %2 = mul i32 %1, 113 ; [#uses=1] - %3 = getelementptr %struct.Foo* %Bar, i64 %i.01, i32 2, i64 3 ; [#uses=1] - store i32 %2, i32* %3, align 4 - %4 = add i64 %i.01, 1 ; [#uses=2] - br label %bb1 - -bb1: ; preds = %bb - %phitmp = icmp sgt i64 %4, 19999 ; [#uses=1] - br i1 %phitmp, label %bb1.return_crit_edge, label %bb - -bb1.return_crit_edge: ; preds = %bb1 - br label %return - -return: ; preds = %bb1.return_crit_edge, %entry - ret void -} diff --git a/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll b/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll index 22e209283b76..f619e8d127ec 100644 --- a/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll +++ b/test/Transforms/IndVarSimplify/preserve-signed-wrap.ll @@ -1,5 +1,4 @@ ; RUN: opt < %s -indvars -S | FileCheck %s -; RUN: opt < %s -indvars -enable-iv-rewrite=false -S | FileCheck %s ; Indvars should insert a 64-bit induction variable to eliminate the ; sext for the addressing, however it shouldn't eliminate the sext diff --git a/test/Transforms/IndVarSimplify/sink-alloca.ll b/test/Transforms/IndVarSimplify/sink-alloca.ll index 3a6c683e7cec..64207d823d2c 100644 --- a/test/Transforms/IndVarSimplify/sink-alloca.ll +++ b/test/Transforms/IndVarSimplify/sink-alloca.ll @@ -1,15 +1,10 @@ ; RUN: opt < %s -indvars -S | FileCheck %s -; PR4775 - -; Indvars shouldn't sink the alloca out of the entry block, even though -; it's not used until after the loop. - 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 = "i386-apple-darwin10.0" -@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @main to i8*)], -section "llvm.metadata" ; <[1 x i8*]*> [#uses=0] - +; PR4775 +; Indvars shouldn't sink the alloca out of the entry block, even though +; it's not used until after the loop. define i32 @main() nounwind { ; CHECK: entry: ; CHECK-NEXT: %result.i = alloca i32, align 4 @@ -23,9 +18,39 @@ while.cond: ; preds = %while.cond, %entry br i1 %tobool, label %while.end, label %while.cond while.end: ; preds = %while.cond - volatile store i32 0, i32* %result.i - %tmp.i = volatile load i32* %result.i ; [#uses=0] + store volatile i32 0, i32* %result.i + %tmp.i = load volatile i32* %result.i ; [#uses=0] ret i32 0 } - declare i32 @bar() + +; +; Indvars shouldn't sink the first alloca between the stacksave and stackrestore +; intrinsics. +declare i8* @a(...) +declare i8* @llvm.stacksave() nounwind +declare void @llvm.stackrestore(i8*) nounwind +define void @h(i64 %n) nounwind uwtable ssp { +; CHECK: entry: +; CHECK-NEXT: %vla = alloca i8* +; CHECK-NEXT: %savedstack = call i8* @llvm.stacksave() +entry: + %vla = alloca i8*, i64 %n, align 16 + %savedstack = call i8* @llvm.stacksave() nounwind + %vla.i = alloca i8*, i64 %n, align 16 + br label %for.body.i + +for.body.i: + %indvars.iv37.i = phi i64 [ %indvars.iv.next38.i, %for.body.i ], [ 0, %entry ] + %call.i = call i8* (...)* @a() nounwind + %arrayidx.i = getelementptr inbounds i8** %vla.i, i64 %indvars.iv37.i + store i8* %call.i, i8** %arrayidx.i, align 8 + %indvars.iv.next38.i = add i64 %indvars.iv37.i, 1 + %exitcond5 = icmp eq i64 %indvars.iv.next38.i, %n + br i1 %exitcond5, label %g.exit, label %for.body.i + +g.exit: + call void @llvm.stackrestore(i8* %savedstack) nounwind + %call1 = call i8* (...)* @a(i8** %vla) nounwind + ret void +} diff --git a/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll b/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll index fc906cdcfb15..fb9ef22549c0 100644 --- a/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll +++ b/test/Transforms/IndVarSimplify/variable-stride-ivs-0.ll @@ -1,5 +1,4 @@ ; RUN: opt < %s -indvars -instcombine -S | FileCheck %s -; RUN: opt < %s -indvars -enable-iv-rewrite=false -instcombine -S | FileCheck %s ; ; 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 diff --git a/test/Transforms/Inline/2007-06-06-NoInline.ll b/test/Transforms/Inline/2007-06-06-NoInline.ll deleted file mode 100644 index d5a7953ffb07..000000000000 --- a/test/Transforms/Inline/2007-06-06-NoInline.ll +++ /dev/null @@ -1,46 +0,0 @@ -; RUN: opt < %s -inline -S | grep "define internal i32 @bar" -@llvm.noinline = appending global [1 x i8*] [ i8* bitcast (i32 (i32, i32)* @bar to i8*) ], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0] - -define internal i32 @bar(i32 %x, i32 %y) { -entry: - %x_addr = alloca i32 ; [#uses=2] - %y_addr = alloca i32 ; [#uses=2] - %retval = alloca i32, align 4 ; [#uses=2] - %tmp = alloca i32, align 4 ; [#uses=2] - %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] - store i32 %x, i32* %x_addr - store i32 %y, i32* %y_addr - %tmp1 = load i32* %x_addr ; [#uses=1] - %tmp2 = load i32* %y_addr ; [#uses=1] - %tmp3 = add i32 %tmp1, %tmp2 ; [#uses=1] - store i32 %tmp3, i32* %tmp - %tmp4 = load i32* %tmp ; [#uses=1] - store i32 %tmp4, i32* %retval - br label %return - -return: ; preds = %entry - %retval5 = load i32* %retval ; [#uses=1] - ret i32 %retval5 -} - -define i32 @foo(i32 %a, i32 %b) { -entry: - %a_addr = alloca i32 ; [#uses=2] - %b_addr = alloca i32 ; [#uses=2] - %retval = alloca i32, align 4 ; [#uses=2] - %tmp = alloca i32, align 4 ; [#uses=2] - %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] - store i32 %a, i32* %a_addr - store i32 %b, i32* %b_addr - %tmp1 = load i32* %b_addr ; [#uses=1] - %tmp2 = load i32* %a_addr ; [#uses=1] - %tmp3 = call i32 @bar( i32 %tmp1, i32 %tmp2 ) ; [#uses=1] - store i32 %tmp3, i32* %tmp - %tmp4 = load i32* %tmp ; [#uses=1] - store i32 %tmp4, i32* %retval - br label %return - -return: ; preds = %entry - %retval5 = load i32* %retval ; [#uses=1] - ret i32 %retval5 -} diff --git a/test/Transforms/Inline/2008-09-02-AlwaysInline.ll b/test/Transforms/Inline/2008-09-02-AlwaysInline.ll deleted file mode 100644 index 39095c407281..000000000000 --- a/test/Transforms/Inline/2008-09-02-AlwaysInline.ll +++ /dev/null @@ -1,10 +0,0 @@ -; RUN: opt < %s -inline-threshold=0 -inline -S | not grep call - -define i32 @fn2() alwaysinline { - ret i32 1 -} - -define i32 @fn3() { - %r = call i32 @fn2() - ret i32 %r -} diff --git a/test/Transforms/Inline/2008-10-30-AlwaysInline.ll b/test/Transforms/Inline/2008-10-30-AlwaysInline.ll deleted file mode 100644 index 11e501274d3b..000000000000 --- a/test/Transforms/Inline/2008-10-30-AlwaysInline.ll +++ /dev/null @@ -1,14 +0,0 @@ -; RUN: opt < %s -always-inline -S | not grep call - -; Ensure that threshold doesn't disrupt always inline. -; RUN: opt < %s -inline-threshold=-2000000001 -always-inline -S | not grep call - - -define internal i32 @if0() alwaysinline { - ret i32 1 -} - -define i32 @f0() { - %r = call i32 @if0() - ret i32 %r -} diff --git a/test/Transforms/Inline/2008-11-04-AlwaysInline.ll b/test/Transforms/Inline/2008-11-04-AlwaysInline.ll deleted file mode 100644 index bc9787b82345..000000000000 --- a/test/Transforms/Inline/2008-11-04-AlwaysInline.ll +++ /dev/null @@ -1,7 +0,0 @@ -; RUN: opt < %s -always-inline -S | grep {@foo} -; Ensure that foo is not removed by always inliner -; PR 2945 - -define internal i32 @foo() nounwind { - ret i32 0 -} diff --git a/test/Transforms/Inline/alloca-bonus.ll b/test/Transforms/Inline/alloca-bonus.ll new file mode 100644 index 000000000000..d04d54e3a538 --- /dev/null +++ b/test/Transforms/Inline/alloca-bonus.ll @@ -0,0 +1,155 @@ +; RUN: opt -inline < %s -S -o - -inline-threshold=8 | FileCheck %s + +target datalayout = "p:32:32" + +declare void @llvm.lifetime.start(i64 %size, i8* nocapture %ptr) + +@glbl = external global i32 + +define void @outer1() { +; CHECK: @outer1 +; CHECK-NOT: call void @inner1 + %ptr = alloca i32 + call void @inner1(i32* %ptr) + ret void +} + +define void @inner1(i32 *%ptr) { + %A = load i32* %ptr + store i32 0, i32* %ptr + %C = getelementptr inbounds i32* %ptr, i32 0 + %D = getelementptr inbounds i32* %ptr, i32 1 + %E = bitcast i32* %ptr to i8* + %F = select i1 false, i32* %ptr, i32* @glbl + call void @llvm.lifetime.start(i64 0, i8* %E) + ret void +} + +define void @outer2() { +; CHECK: @outer2 +; CHECK: call void @inner2 + %ptr = alloca i32 + call void @inner2(i32* %ptr) + ret void +} + +; %D poisons this call, scalar-repl can't handle that instruction. +define void @inner2(i32 *%ptr) { + %A = load i32* %ptr + store i32 0, i32* %ptr + %C = getelementptr inbounds i32* %ptr, i32 0 + %D = getelementptr inbounds i32* %ptr, i32 %A + %E = bitcast i32* %ptr to i8* + %F = select i1 false, i32* %ptr, i32* @glbl + call void @llvm.lifetime.start(i64 0, i8* %E) + ret void +} + +define void @outer3() { +; CHECK: @outer3 +; CHECK-NOT: call void @inner3 + %ptr = alloca i32 + call void @inner3(i32* %ptr, i1 undef) + ret void +} + +define void @inner3(i32 *%ptr, i1 %x) { + %A = icmp eq i32* %ptr, null + %B = and i1 %x, %A + br i1 %A, label %bb.true, label %bb.false +bb.true: + ; This block musn't be counted in the inline cost. + %t1 = load i32* %ptr + %t2 = add i32 %t1, 1 + %t3 = add i32 %t2, 1 + %t4 = add i32 %t3, 1 + %t5 = add i32 %t4, 1 + %t6 = add i32 %t5, 1 + %t7 = add i32 %t6, 1 + %t8 = add i32 %t7, 1 + %t9 = add i32 %t8, 1 + %t10 = add i32 %t9, 1 + %t11 = add i32 %t10, 1 + %t12 = add i32 %t11, 1 + %t13 = add i32 %t12, 1 + %t14 = add i32 %t13, 1 + %t15 = add i32 %t14, 1 + %t16 = add i32 %t15, 1 + %t17 = add i32 %t16, 1 + %t18 = add i32 %t17, 1 + %t19 = add i32 %t18, 1 + %t20 = add i32 %t19, 1 + ret void +bb.false: + ret void +} + +define void @outer4(i32 %A) { +; CHECK: @outer4 +; CHECK-NOT: call void @inner4 + %ptr = alloca i32 + call void @inner4(i32* %ptr, i32 %A) + ret void +} + +; %B poisons this call, scalar-repl can't handle that instruction. However, we +; still want to detect that the icmp and branch *can* be handled. +define void @inner4(i32 *%ptr, i32 %A) { + %B = getelementptr inbounds i32* %ptr, i32 %A + %C = icmp eq i32* %ptr, null + br i1 %C, label %bb.true, label %bb.false +bb.true: + ; This block musn't be counted in the inline cost. + %t1 = load i32* %ptr + %t2 = add i32 %t1, 1 + %t3 = add i32 %t2, 1 + %t4 = add i32 %t3, 1 + %t5 = add i32 %t4, 1 + %t6 = add i32 %t5, 1 + %t7 = add i32 %t6, 1 + %t8 = add i32 %t7, 1 + %t9 = add i32 %t8, 1 + %t10 = add i32 %t9, 1 + %t11 = add i32 %t10, 1 + %t12 = add i32 %t11, 1 + %t13 = add i32 %t12, 1 + %t14 = add i32 %t13, 1 + %t15 = add i32 %t14, 1 + %t16 = add i32 %t15, 1 + %t17 = add i32 %t16, 1 + %t18 = add i32 %t17, 1 + %t19 = add i32 %t18, 1 + %t20 = add i32 %t19, 1 + ret void +bb.false: + ret void +} + +define void @outer5() { +; CHECK: @outer5 +; CHECK-NOT: call void @inner5 + %ptr = alloca i32 + call void @inner5(i1 false, i32* %ptr) + ret void +} + +; %D poisons this call, scalar-repl can't handle that instruction. However, if +; the flag is set appropriately, the poisoning instruction is inside of dead +; code, and so shouldn't be counted. +define void @inner5(i1 %flag, i32 *%ptr) { + %A = load i32* %ptr + store i32 0, i32* %ptr + %C = getelementptr inbounds i32* %ptr, i32 0 + br i1 %flag, label %if.then, label %exit + +if.then: + %D = getelementptr inbounds i32* %ptr, i32 %A + %E = bitcast i32* %ptr to i8* + %F = select i1 false, i32* %ptr, i32* @glbl + call void @llvm.lifetime.start(i64 0, i8* %E) + ret void + +exit: + ret void +} + diff --git a/test/Transforms/Inline/always-inline.ll b/test/Transforms/Inline/always-inline.ll new file mode 100644 index 000000000000..e0be41fa6657 --- /dev/null +++ b/test/Transforms/Inline/always-inline.ll @@ -0,0 +1,125 @@ +; RUN: opt < %s -inline-threshold=0 -always-inline -S | FileCheck %s +; +; Ensure the threshold has no impact on these decisions. +; RUN: opt < %s -inline-threshold=20000000 -always-inline -S | FileCheck %s +; RUN: opt < %s -inline-threshold=-20000000 -always-inline -S | FileCheck %s + +define i32 @inner1() alwaysinline { + ret i32 1 +} +define i32 @outer1() { +; CHECK: @outer1 +; CHECK-NOT: call +; CHECK: ret + + %r = call i32 @inner1() + ret i32 %r +} + +; The always inliner can't DCE internal functions. PR2945 +; CHECK: @pr2945 +define internal i32 @pr2945() nounwind { + ret i32 0 +} + +define internal void @inner2(i32 %N) alwaysinline { + %P = alloca i32, i32 %N + ret void +} +define void @outer2(i32 %N) { +; The always inliner (unlike the normal one) should be willing to inline +; a function with a dynamic alloca into one without a dynamic alloca. +; rdar://6655932 +; +; CHECK: @outer2 +; CHECK-NOT: call void @inner2 +; CHECK alloca i32, i32 %N +; CHECK-NOT: call void @inner2 +; CHECK: ret void + + call void @inner2( i32 %N ) + ret void +} + +declare i32 @a() returns_twice +declare i32 @b() returns_twice + +define i32 @inner3() alwaysinline { +entry: + %call = call i32 @a() returns_twice + %add = add nsw i32 1, %call + ret i32 %add +} +define i32 @outer3() { +entry: +; CHECK: @outer3 +; CHECK-NOT: call i32 @a +; CHECK: ret + + %call = call i32 @inner3() + %add = add nsw i32 1, %call + ret i32 %add +} + +define i32 @inner4() alwaysinline returns_twice { +entry: + %call = call i32 @b() returns_twice + %add = add nsw i32 1, %call + ret i32 %add +} + +define i32 @outer4() { +entry: +; CHECK: @outer4 +; CHECK: call i32 @b() +; CHECK: ret + + %call = call i32 @inner4() returns_twice + %add = add nsw i32 1, %call + ret i32 %add +} + +define i32 @inner5(i8* %addr) alwaysinline { +entry: + indirectbr i8* %addr, [ label %one, label %two ] + +one: + ret i32 42 + +two: + ret i32 44 +} +define i32 @outer5(i32 %x) { +; CHECK: @outer5 +; CHECK: call i32 @inner5 +; CHECK: ret + + %cmp = icmp slt i32 %x, 42 + %addr = select i1 %cmp, i8* blockaddress(@inner5, %one), i8* blockaddress(@inner5, %two) + %call = call i32 @inner5(i8* %addr) + ret i32 %call +} + +define void @inner6(i32 %x) alwaysinline { +entry: + %icmp = icmp slt i32 %x, 0 + br i1 %icmp, label %return, label %bb + +bb: + %sub = sub nsw i32 %x, 1 + call void @inner6(i32 %sub) + ret void + +return: + ret void +} +define void @outer6() { +; CHECK: @outer6 +; CHECK: call void @inner6(i32 42) +; CHECK: ret + +entry: + call void @inner6(i32 42) + ret void +} + diff --git a/test/Transforms/Inline/always_inline_dyn_alloca.ll b/test/Transforms/Inline/always_inline_dyn_alloca.ll deleted file mode 100644 index 25cfc49f1a84..000000000000 --- a/test/Transforms/Inline/always_inline_dyn_alloca.ll +++ /dev/null @@ -1,15 +0,0 @@ -; RUN: opt < %s -inline -S | not grep callee -; rdar://6655932 - -; If callee is marked alwaysinline, inline it! Even if callee has dynamic -; alloca and caller does not, - -define internal void @callee(i32 %N) alwaysinline { - %P = alloca i32, i32 %N - ret void -} - -define void @foo(i32 %N) { - call void @callee( i32 %N ) - ret void -} diff --git a/test/Transforms/Inline/blockaddress.ll b/test/Transforms/Inline/blockaddress.ll new file mode 100644 index 000000000000..4206312d7743 --- /dev/null +++ b/test/Transforms/Inline/blockaddress.ll @@ -0,0 +1,27 @@ +; RUN: opt -inline -S < %s | FileCheck %s +; PR10162 + +; Make sure the blockaddress is mapped correctly when doit is inlined +; CHECK: store i8* blockaddress(@f, %here.i), i8** @ptr1, align 8 + +@i = global i32 1, align 4 +@ptr1 = common global i8* null, align 8 + +define void @doit(i8** nocapture %pptr, i32 %cond) nounwind uwtable { +entry: + %tobool = icmp eq i32 %cond, 0 + br i1 %tobool, label %if.end, label %here + +here: + store i8* blockaddress(@doit, %here), i8** %pptr, align 8 + br label %if.end + +if.end: + ret void +} + +define void @f(i32 %cond) nounwind uwtable { +entry: + call void @doit(i8** @ptr1, i32 %cond) + ret void +} diff --git a/test/Transforms/Inline/dg.exp b/test/Transforms/Inline/dg.exp deleted file mode 100644 index f2005891a59a..000000000000 --- a/test/Transforms/Inline/dg.exp +++ /dev/null @@ -1,3 +0,0 @@ -load_lib llvm.exp - -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] diff --git a/test/Transforms/Inline/dynamic_alloca_test.ll b/test/Transforms/Inline/dynamic_alloca_test.ll index 0286535efec1..15a5c66815d2 100644 --- a/test/Transforms/Inline/dynamic_alloca_test.ll +++ b/test/Transforms/Inline/dynamic_alloca_test.ll @@ -3,33 +3,43 @@ ; Functions with dynamic allocas can only be inlined into functions that ; already have dynamic allocas. -; RUN: opt < %s -inline -S | \ -; RUN: grep llvm.stacksave -; RUN: opt < %s -inline -S | not grep callee - +; RUN: opt < %s -inline -S | FileCheck %s +; +; FIXME: This test is xfailed because the inline cost rewrite disabled *all* +; inlining of functions which contain a dynamic alloca. It should be re-enabled +; once that functionality is restored. +; XFAIL: * declare void @ext(i32*) define internal void @callee(i32 %N) { - %P = alloca i32, i32 %N ; [#uses=1] - call void @ext( i32* %P ) - ret void + %P = alloca i32, i32 %N + call void @ext(i32* %P) + ret void } define void @foo(i32 %N) { -;