[llvm] r314517 - Use the basic cost if a GEP is not used as addressing mode

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 14:08:04 PDT 2017


This bot fails after the patch

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/4176/steps/check-msan%20in%20gcc%20build/logs/stdio


7 warnings generated.
clang-6.0: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Support/Casting.h:255:
typename llvm::cast_retty<X, Y*>::ret_type llvm::cast(Y*) [with X =
llvm::Operator; Y = const llvm::User; typename llvm::cast_retty<X,
Y*>::ret_type = const llvm::Operator*]: Assertion `isa<X>(Val) &&
"cast<Ty>() argument of incompatible type!"' failed.
#0 0x0000000001f90f1a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Unix/Signals.inc:402:0
#1 0x0000000001f8ed7e llvm::sys::RunSignalHandlers()
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Signals.cpp:50:0
#2 0x0000000001f8eef2 SignalHandler(int)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Support/Unix/Signals.inc:242:0
#3 0x00007f835e2fc390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
#4 0x00007f835d288428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428)
#5 0x00007f835d28a02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a)
#6 0x00007f835d280bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7)
#7 0x00007f835d280c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
#8 0x0000000001352326 llvm::cast_retty<llvm::Operator, llvm::User
const*>::ret_type llvm::cast<llvm::Operator, llvm::User
const>(llvm::User const*)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Support/Casting.h:255:0
#9 0x0000000001352326
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getGEPCost(llvm::GEPOperator
const*, llvm::ArrayRef<llvm::Value const*>)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:742:0
#10 0x000000000135266d
llvm::TargetTransformInfoImplCRTPBase<llvm::X86TTIImpl>::getUserCost(llvm::User
const*, llvm::ArrayRef<llvm::Value const*>)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h:782:0
#11 0x00000000016eab12
llvm::TargetTransformInfo::getUserCost(llvm::User const*,
llvm::ArrayRef<llvm::Value const*>) const
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/TargetTransformInfo.cpp:116:0
#12 0x0000000002051b06 llvm::SmallVectorTemplateCommon<llvm::Value
const*, void>::begin()
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ADT/SmallVector.h:116:0
#13 0x0000000002051b06 llvm::SmallVectorImpl<llvm::Value
const*>::~SmallVectorImpl()
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ADT/SmallVector.h:343:0
#14 0x0000000002051b06 llvm::SmallVector<llvm::Value const*,
4u>::~SmallVector()
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/ADT/SmallVector.h:864:0
#15 0x0000000002051b06
llvm::TargetTransformInfo::getUserCost(llvm::User const*) const
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Analysis/TargetTransformInfo.h:285:0
#16 0x0000000002051b06 ComputeSpeculationCost(llvm::User const*,
llvm::TargetTransformInfo const&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:299:0
#17 0x000000000205e167 SpeculativelyExecuteBB(llvm::BranchInst*,
llvm::BasicBlock*, llvm::TargetTransformInfo const&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:2003:0
#18 0x00000000020651a5 SimplifyCondBranch
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5835:0
#19 0x00000000020651a5 run
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5986:0
#20 0x00000000020651a5 llvm::SimplifyCFG(llvm::BasicBlock*,
llvm::TargetTransformInfo const&, llvm::AssumptionCache*,
llvm::SimplifyCFGOptions const&,
llvm::SmallPtrSetImpl<llvm::BasicBlock*>*)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6020:0
#21 0x0000000001ef709a iterativelySimplifyCFG(llvm::Function&,
llvm::TargetTransformInfo const&, llvm::AssumptionCache*,
llvm::SimplifyCFGOptions const&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:148:0
#22 0x0000000001ef74ac simplifyFunctionCFG(llvm::Function&,
llvm::TargetTransformInfo const&, llvm::AssumptionCache*,
llvm::SimplifyCFGOptions const&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:166:0
#23 0x0000000001ef8109 (anonymous
namespace)::BaseCFGSimplifyPass::runOnFunction(llvm::Function&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:226:0
#24 0x0000000001afcfbb
llvm::FPPassManager::runOnFunction(llvm::Function&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/LegacyPassManager.cpp:1514:0
#25 0x00000000015c1b0e RunPassOnSCC
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/CallGraphSCCPass.cpp:156:0
#26 0x00000000015c1b0e RunAllPassesOnSCC
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/CallGraphSCCPass.cpp:424:0
#27 0x00000000015c1b0e (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/Analysis/CallGraphSCCPass.cpp:479:0
#28 0x0000000001afcbbd runOnModule
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/LegacyPassManager.cpp:1591:0
#29 0x0000000001afcbbd
llvm::legacy::PassManagerImpl::run(llvm::Module&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/lib/IR/LegacyPassManager.cpp:1694:0
#30 0x000000000213496e
llvm::PrettyStackTraceString::~PrettyStackTraceString()
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/include/llvm/Support/PrettyStackTrace.h:52:0
#31 0x000000000213496e EmitAssembly
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:788:0
#32 0x000000000213496e
clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&,
llvm::DataLayout const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/BackendUtil.cpp:1145:0
#33 0x000000000281d997 std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >::~unique_ptr()
/usr/include/c++/5/bits/unique_ptr.h:235:0
#34 0x000000000281d997
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:292:0
#35 0x0000000002bc0958 void std::swap<bool>(bool&, bool&)
/usr/include/c++/5/bits/move.h:187:0
#36 0x0000000002bc0958 clang::ParseAST(clang::Sema&, bool, bool)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:161:0
#37 0x000000000281ce2f clang::CodeGenAction::ExecuteAction()
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/CodeGen/CodeGenAction.cpp:1024:0
#38 0x00000000024d7746 clang::FrontendAction::Execute()
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:897:0
#39 0x00000000024a7f66
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:991:0
#40 0x0000000002565a12
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:252:0
#41 0x00000000009ec5a8 cc1_main(llvm::ArrayRef<char const*>, char
const*, void*) /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/tools/driver/cc1_main.cpp:221:0
#42 0x00000000009741d2 ExecuteCC1Tool
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/tools/driver/driver.cpp:309:0
#43 0x00000000009741d2 main
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/tools/clang/tools/driver/driver.cpp:388:0
#44 0x00007f835d273830 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x20830)
#45 0x00000000009e8eb9 _start
(/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/bin/clang-6.0+0x9e8eb9)
Stack dump:
0.      Program arguments:
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/bin/clang-6.0
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free
-main-file-name path.cpp -mrelocation-model pic -pic-level 2
-mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases
-munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info
-debugger-tuning=gdb -momit-leaf-frame-pointer -coverage-notes-file
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/lib/msan/libcxx_msan_x86_64/src/libcxx_msan_x86_64-build/lib/CMakeFiles/cxx_experimental.dir/__/src/experimental/filesystem/path.cpp.gcno
-nostdinc++ -resource-dir
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/lib/clang/6.0.0
-D NDEBUG -D _LIBCPP_BUILDING_LIBRARY -D
_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -I
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/libcxx/include
-D NDEBUG -internal-isystem /usr/local/include -internal-isystem
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/lib/clang/6.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem
/usr/include -O3 -Wall -Wextra -W -Wwrite-strings
-Wno-unused-parameter -Wno-long-long -Werror=return-type
-Wno-user-defined-literals -Wno-covered-switch-default -Wno-error
-std=c++14 -fdeprecated-macro -fdebug-compilation-dir
/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/projects/compiler-rt/lib/msan/libcxx_msan_x86_64/src/libcxx_msan_x86_64-build/lib
-ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden
-fsanitize=memory
-fsanitize-blacklist=/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/lib/clang/6.0.0/msan_blacklist.txt
-fsanitize-memory-track-origins=2 -fno-assume-sane-operator-new
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -vectorize-loops -vectorize-slp -o
CMakeFiles/cxx_experimental.dir/__/src/experimental/filesystem/path.cpp.o
-x c++ /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/libcxx/src/experimental/filesystem/path.cpp
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module
'/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/libcxx/src/experimental/filesystem/path.cpp'.
4.      Running pass 'Simplify the CFG' on function
'@_ZNKSt12experimental10filesystem2v14path16__root_directoryEv'
clang-6.0: error: unable to execute command: Aborted (core dumped)
clang-6.0: error: clang frontend command failed due to signal (use -v
to see invocation)
clang version 6.0.0 (trunk 314517)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/clang_build/./bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed
source, and associated run script.
clang-6.0: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-6.0: note: diagnostic msg: /tmp/path-ecf8e5.cpp
clang-6.0: note: diagnostic msg: /tmp/path-ecf8e5.sh
clang-6.0: note: diagnostic msg:

********************
make[6]: *** [lib/CMakeFiles/cxx_experimental.dir/__/src/experimental/filesystem/path.cpp.o]
Error 254
make[6]: *** Waiting for unfinished jobs....
make[5]: *** [lib/CMakeFiles/cxx_experimental.dir/all] Error 2
make[4]: *** [all] Error 2
Scanning dependencies of target cxx_objects


On Fri, Sep 29, 2017 at 7:50 AM, Jun Bum Lim via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: junbuml
> Date: Fri Sep 29 07:50:16 2017
> New Revision: 314517
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314517&view=rev
> Log:
> Use the basic cost if a GEP is not used as addressing mode
>
> Summary:
> Currently, getGEPCost() returns TCC_FREE whenever a GEP is a legal
> addressing mode in the target.
> However, since it doesn't check its actual users, it will return FREE even
> in cases
> where the GEP cannot be folded away as a part of actual addressing mode.
> For example, if an user of the GEP is a call instruction taking the GEP as
> a parameter,
> then the GEP may not be folded in isel.
>
> Reviewers: hfinkel, efriedma, mcrosier, jingyue, haicheng
>
> Reviewed By: hfinkel
>
> Subscribers: javed.absar, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D38085
>
> Modified:
>     llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h
>     llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
>     llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h
>     llvm/trunk/include/llvm/IR/Operator.h
>     llvm/trunk/lib/Analysis/TargetTransformInfo.cpp
>     llvm/trunk/lib/Transforms/Scalar/NaryReassociate.cpp
>     llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
>     llvm/trunk/test/Analysis/CostModel/AArch64/gep.ll
>     llvm/trunk/test/Analysis/CostModel/X86/vector_gep.ll
>
> Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/
> TargetTransformInfo.h?rev=314517&r1=314516&r2=314517&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h (original)
> +++ llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h Fri Sep 29
> 07:50:16 2017
> @@ -193,6 +193,13 @@ public:
>    int getGEPCost(Type *PointeeType, const Value *Ptr,
>                   ArrayRef<const Value *> Operands) const;
>
> +  /// \brief Estimate the cost of a GEP operation when lowered.
> +  ///
> +  /// This user-based overload adds the ability to check if the GEP can be
> +  /// folded into its users.
> +  int getGEPCost(const GEPOperator *GEP,
> +                 ArrayRef<const Value *> Operands) const;
> +
>    /// \brief Estimate the cost of a EXT operation when lowered.
>    ///
>    /// The contract for this function is the same as \c getOperationCost
> except
> @@ -251,9 +258,9 @@ public:
>    /// \brief Estimate the cost of a given IR user when lowered.
>    ///
>    /// This can estimate the cost of either a ConstantExpr or Instruction
> when
> -  /// lowered. It has two primary advantages over the \c getOperationCost
> and
> -  /// \c getGEPCost above, and one significant disadvantage: it can only
> be
> -  /// used when the IR construct has already been formed.
> +  /// lowered. It has two primary advantages over the \c getOperationCost
> above,
> +  /// and one significant disadvantage: it can only be used when the IR
> +  /// construct has already been formed.
>    ///
>    /// The advantages are that it can inspect the SSA use graph to reason
> more
>    /// accurately about the cost. For example, all-constant-GEPs can often
> be
> @@ -932,6 +939,8 @@ public:
>    virtual int getOperationCost(unsigned Opcode, Type *Ty, Type *OpTy) = 0;
>    virtual int getGEPCost(Type *PointeeType, const Value *Ptr,
>                           ArrayRef<const Value *> Operands) = 0;
> +  virtual int getGEPCost(const GEPOperator *GEP,
> +                         ArrayRef<const Value *> Operands) = 0;
>    virtual int getExtCost(const Instruction *I, const Value *Src) = 0;
>    virtual int getCallCost(FunctionType *FTy, int NumArgs) = 0;
>    virtual int getCallCost(const Function *F, int NumArgs) = 0;
> @@ -1113,6 +1122,10 @@ public:
>                   ArrayRef<const Value *> Operands) override {
>      return Impl.getGEPCost(PointeeType, Ptr, Operands);
>    }
> +  int getGEPCost(const GEPOperator *GEP,
> +                 ArrayRef<const Value *> Operands) override {
> +    return Impl.getGEPCost(GEP, Operands);
> +  }
>    int getExtCost(const Instruction *I, const Value *Src) override {
>      return Impl.getExtCost(I, Src);
>    }
>
> Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/
> TargetTransformInfoImpl.h?rev=314517&r1=314516&r2=314517&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h (original)
> +++ llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h Fri Sep 29
> 07:50:16 2017
> @@ -726,6 +726,35 @@ public:
>      return TTI::TCC_Basic;
>    }
>
> +  int getGEPCost(const GEPOperator *GEP, ArrayRef<const Value *>
> Operands) {
> +    Type *PointeeType = GEP->getSourceElementType();
> +    const Value *Ptr = GEP->getPointerOperand();
> +
> +    if (getGEPCost(PointeeType, Ptr, Operands) == TTI::TCC_Free) {
> +      // Should check if the GEP is actually used in load / store
> instructions.
> +      // For simplicity, we check only direct users of the GEP.
> +      //
> +      // FIXME: GEPs could also be folded away as a part of addressing
> mode in
> +      // load/store instructions together with other instructions (e.g.,
> other
> +      // GEPs). Handling all such cases must be expensive to be performed
> +      // in this function, so we stay conservative for now.
> +      for (const User *U : GEP->users()) {
> +        const Operator *UOP = cast<Operator>(U);
> +        const Value *PointerOperand = nullptr;
> +        if (auto *LI = dyn_cast<LoadInst>(UOP))
> +          PointerOperand = LI->getPointerOperand();
> +        else if (auto *SI = dyn_cast<StoreInst>(UOP))
> +          PointerOperand = SI->getPointerOperand();
> +
> +        if ((!PointerOperand || PointerOperand != GEP) &&
> +            !GEP->hasAllZeroIndices())
> +          return TTI::TCC_Basic;
> +      }
> +      return TTI::TCC_Free;
> +    }
> +    return TTI::TCC_Basic;
> +  }
> +
>    using BaseT::getIntrinsicCost;
>
>    unsigned getIntrinsicCost(Intrinsic::ID IID, Type *RetTy,
> @@ -749,11 +778,8 @@ public:
>        if (A->isStaticAlloca())
>          return TTI::TCC_Free;
>
> -    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U)) {
> -      return static_cast<T *>(this)->getGEPCost(GEP->
> getSourceElementType(),
> -                                                GEP->getPointerOperand(),
> -                                                Operands.drop_front());
> -    }
> +    if (const GEPOperator *GEP = dyn_cast<GEPOperator>(U))
> +      return static_cast<T *>(this)->getGEPCost(GEP,
> Operands.drop_front());
>
>      if (auto CS = ImmutableCallSite(U)) {
>        const Function *F = CS.getCalledFunction();
>
> Modified: llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/CodeGen/BasicTTIImpl.h?rev=314517&r1=314516&r2=314517&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h Fri Sep 29 07:50:16
> 2017
> @@ -151,6 +151,10 @@ public:
>      return BaseT::getGEPCost(PointeeType, Ptr, Operands);
>    }
>
> +  int getGEPCost(const GEPOperator *GEP, ArrayRef<const Value *>
> Operands) {
> +    return BaseT::getGEPCost(GEP, Operands);
> +  }
> +
>    int getExtCost(const Instruction *I, const Value *Src) {
>      if (getTLI()->isExtFree(I))
>        return TargetTransformInfo::TCC_Free;
>
> Modified: llvm/trunk/include/llvm/IR/Operator.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/IR/Operator.h?rev=314517&r1=314516&r2=314517&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/IR/Operator.h (original)
> +++ llvm/trunk/include/llvm/IR/Operator.h Fri Sep 29 07:50:16 2017
> @@ -456,6 +456,8 @@ public:
>        if (ConstantInt *C = dyn_cast<ConstantInt>(I))
>          if (C->isZero())
>            continue;
> +      if (isa<ConstantAggregateZero>(I))
> +        continue;
>        return false;
>      }
>      return true;
>
> Modified: llvm/trunk/lib/Analysis/TargetTransformInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> Analysis/TargetTransformInfo.cpp?rev=314517&r1=314516&r2=314517&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Analysis/TargetTransformInfo.cpp (original)
> +++ llvm/trunk/lib/Analysis/TargetTransformInfo.cpp Fri Sep 29 07:50:16
> 2017
> @@ -88,6 +88,11 @@ int TargetTransformInfo::getGEPCost(Type
>    return TTIImpl->getGEPCost(PointeeType, Ptr, Operands);
>  }
>
> +int TargetTransformInfo::getGEPCost(const GEPOperator *GEP,
> +                                    ArrayRef<const Value *> Operands)
> const {
> +  return TTIImpl->getGEPCost(GEP, Operands);
> +}
> +
>  int TargetTransformInfo::getExtCost(const Instruction *I,
>                                      const Value *Src) const {
>    return TTIImpl->getExtCost(I, Src);
>
> Modified: llvm/trunk/lib/Transforms/Scalar/NaryReassociate.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/
> NaryReassociate.cpp?rev=314517&r1=314516&r2=314517&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Transforms/Scalar/NaryReassociate.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/NaryReassociate.cpp Fri Sep 29
> 07:50:16 2017
> @@ -264,7 +264,7 @@ static bool isGEPFoldable(GetElementPtrI
>    SmallVector<const Value*, 4> Indices;
>    for (auto I = GEP->idx_begin(); I != GEP->idx_end(); ++I)
>      Indices.push_back(*I);
> -  return TTI->getGEPCost(GEP->getSourceElementType(),
> GEP->getPointerOperand(),
> +  return TTI->getGEPCost(cast<GEPOperator>(GEP),
>                           Indices) == TargetTransformInfo::TCC_Free;
>  }
>
>
> Modified: llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/
> StraightLineStrengthReduce.cpp?rev=314517&r1=314516&r2=314517&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
> (original)
> +++ llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp Fri
> Sep 29 07:50:16 2017
> @@ -239,7 +239,7 @@ static bool isGEPFoldable(GetElementPtrI
>    SmallVector<const Value*, 4> Indices;
>    for (auto I = GEP->idx_begin(); I != GEP->idx_end(); ++I)
>      Indices.push_back(*I);
> -  return TTI->getGEPCost(GEP->getSourceElementType(),
> GEP->getPointerOperand(),
> +  return TTI->getGEPCost(cast<GEPOperator>(GEP),
>                           Indices) == TargetTransformInfo::TCC_Free;
>  }
>
>
> Modified: llvm/trunk/test/Analysis/CostModel/AArch64/gep.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> Analysis/CostModel/AArch64/gep.ll?rev=314517&r1=314516&r2=314517&view=diff
> ============================================================
> ==================
> --- llvm/trunk/test/Analysis/CostModel/AArch64/gep.ll (original)
> +++ llvm/trunk/test/Analysis/CostModel/AArch64/gep.ll Fri Sep 29 07:50:16
> 2017
> @@ -290,3 +290,49 @@ define i64 @test36(i64* %p) {
>    %v = load i64, i64* %a
>    ret i64 %v
>  }
> +
> +; CHECK-LABEL: test37
> +; CHECK: cost of 1 for instruction:  {{.*}} = getelementptr inbounds i8*,
> i8**
> +define i8 @test37(i64 %j, i8** readonly %P) {
> +entry:
> +  %arrayidx0 = getelementptr inbounds i8*, i8** %P, i64 %j
> +  %l1 = call i8* @func(i8** %arrayidx0)
> +  ret i8 0
> +}
> +
> +; CHECK-LABEL: test38
> +; CHECK: cost of 1 for instruction: {{.*}} = getelementptr inbounds i8*,
> i8**
> +define i8 @test38(i8** readonly %P) {
> +entry:
> +  %arrayidx0 = getelementptr inbounds i8*, i8** %P, i64 10
> +  %l1 = call i8* @func(i8** %arrayidx0)
> +  ret i8 0
> +}
> +
> +; CHECK-LABEL:test39
> +; CHECK: cost of 0 for instruction: {{.*}} = getelementptr inbounds i8*,
> i8**
> +define i8 @test39(i8** readonly %P) {
> +entry:
> +  %arrayidx0 = getelementptr inbounds i8*, i8** %P, i64 0
> +  %l1 = call i8* @func(i8** %arrayidx0)
> +  ret i8 0
> +}
> +
> +; CHECK-LABEL:test40
> +; CHECK: cost of 1 for instruction: {{.*}} = getelementptr inbounds i8*,
> i8**
> +define i8** @test40(i8** readonly %P) {
> +entry:
> +  %arrayidx0 = getelementptr inbounds i8*, i8** %P, i64 10
> +  ret i8** %arrayidx0
> +}
> +
> +; CHECK-LABEL:test41
> +; CHECK: cost of 1 for instruction: {{.*}} = getelementptr inbounds i8,
> i8*
> +define i8 @test41(i8* %V, i8** readonly %P) {
> +entry:
> +  %arrayidx0 = getelementptr inbounds i8, i8* %V, i64 10
> +  store i8* %arrayidx0, i8** %P
> +  ret i8 0
> +}
> +
> +declare i8* @func(i8**)
>
> Modified: llvm/trunk/test/Analysis/CostModel/X86/vector_gep.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> Analysis/CostModel/X86/vector_gep.ll?rev=314517&r1=314516&
> r2=314517&view=diff
> ============================================================
> ==================
> --- llvm/trunk/test/Analysis/CostModel/X86/vector_gep.ll (original)
> +++ llvm/trunk/test/Analysis/CostModel/X86/vector_gep.ll Fri Sep 29
> 07:50:16 2017
> @@ -10,7 +10,7 @@ define <4 x i32> @foov(<4 x %struct.S*>
>    %vector = shufflevector <4 x i64> %temp, <4 x i64> undef, <4 x i32>
> zeroinitializer
>  ;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds %struct.S
>    %B = getelementptr inbounds %struct.S, <4 x %struct.S*> %s, <4 x i32>
> zeroinitializer, <4 x i32> zeroinitializer
> -;CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds [1000 x
> i32]
> +;CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds [1000 x
> i32]
>    %arrayidx = getelementptr inbounds [1000 x i32], <4 x [1000 x i32]*>
> %B, <4 x i64> zeroinitializer, <4 x i64> %vector
>    %res = call <4 x i32> @llvm.masked.gather.v4i32.v4p0i32(<4 x i32*>
> %arrayidx, i32 4, <4 x i1> <i1 true, i1 true, i1 true, i1 true>, <4 x i32>
> undef)
>    ret <4 x i32> %res
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170929/d234816e/attachment-0001.html>


More information about the llvm-commits mailing list