[llvm] r359879 - [CodeGenPrepare] limit overflow intrinsic matching to a single basic block

Evgenii Stepanov via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 10:13:48 PDT 2019


Hi,

this crash might be caused by this commit:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/12660/steps/build%20clang%2Fubsan/logs/stdio

0. Program arguments:
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free
-main-file-name CommandLine.cpp -mrelocation-model pic -pic-level 2
-mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu
x86-64 -dwarf-column-info -debug-info-kind=line-tables-only
-dwarf-version=4 -debugger-tuning=gdb -momit-leaf-frame-pointer
-ffunction-sections -fdata-sections -coverage-notes-file
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/Support/CMakeFiles/LLVMSupport.dir/CommandLine.cpp.gcno
-resource-dir /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/lib/clang/9.0.0
-dependency-file
lib/Support/CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o.d
-sys-header-deps -MT
lib/Support/CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o -D
GTEST_HAS_RTTI=0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D
__STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I lib/Support -I
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Support -I
/usr/include/libxml2 -I include -I
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/include -U NDEBUG
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward
-internal-isystem /usr/local/include -internal-isystem
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/lib/clang/9.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem
/usr/include -O3 -Werror=date-time -Werror=unguarded-availability-new
-Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wmissing-field-initializers -Wno-long-long -Wimplicit-fallthrough
-Wcovered-switch-default -Wno-class-memaccess -Wno-noexcept-type
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion
-pedantic -w -std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan
-ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden
-fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,float-divide-by-zero,integer-divide-by-zero,nonnull-attribute,null,object-size,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound
-fsanitize-blacklist=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/utils/sanitizers/ubsan_blacklist.txt
-fdepfile-entry=/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/utils/sanitizers/ubsan_blacklist.txt
-fno-rtti -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -vectorize-loops -vectorize-slp -o
lib/Support/CMakeFiles/LLVMSupport.dir/CommandLine.cpp.o -x c++
/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Support/CommandLine.cpp
-faddrsig
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module
'/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/lib/Support/CommandLine.cpp'.
4. Running pass 'CodeGen Prepare' on function
'@_ZN12_GLOBAL__N_117CommandLineParser23ParseCommandLineOptionsEiPKPKcN4llvm9StringRefEPNS5_11raw_ostreamE'
 #0 0x000055d2f954521a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x298521a)
 #1 0x000055d2f9543175 llvm::sys::RunSignalHandlers()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x2983175)
 #2 0x000055d2f954328c SignalHandler(int)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x298328c)
 #3 0x00007f0bd09f40e0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x110e0)
 #4 0x000055d2f8fb84f0
llvm::ReplaceableMetadataImpl::getIfExists(llvm::Metadata&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x23f84f0)
 #5 0x000055d2f8fb8569 llvm::MetadataTracking::untrack(void*,
llvm::Metadata&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x23f8569)
 #6 0x000055d2f8f742b4 llvm::Instruction::~Instruction()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x23b42b4)
 #7 0x000055d2f8fef140 llvm::Value::deleteValue()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x242f140)
 #8 0x000055d2f8b53944 (anonymous
namespace)::CodeGenPrepare::runOnFunction(llvm::Function&)
(.part.1278) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x1f93944)
 #9 0x000055d2f8fa8710
llvm::FPPassManager::runOnFunction(llvm::Function&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x23e8710)
#10 0x000055d2f8fa892c llvm::FPPassManager::runOnModule(llvm::Module&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x23e892c)
#11 0x000055d2f8fa9454
llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x23e9454)
#12 0x000055d2f973ed37 (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x2b7ed37)
#13 0x000055d2f974063c
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> >)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x2b8063c)
#14 0x000055d2fa11f628
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x355f628)
#15 0x000055d2fa982319 clang::ParseAST(clang::Sema&, bool, bool)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x3dc2319)
#16 0x000055d2fa11e8b9 clang::CodeGenAction::ExecuteAction()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x355e8b9)
#17 0x000055d2f9bcfbbe clang::FrontendAction::Execute()
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x300fbbe)
#18 0x000055d2f9b97b96
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x2fd7b96)
#19 0x000055d2f9c73271
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0x30b3271)
#20 0x000055d2f7a5db77 cc1_main(llvm::ArrayRef<char const*>, char
const*, void*) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0xe9db77)
#21 0x000055d2f79c812d main
(/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-9+0xe0812d)


On Fri, May 3, 2019 at 6:06 AM Sanjay Patel via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
> Author: spatel
> Date: Fri May  3 06:09:18 2019
> New Revision: 359879
>
> URL: http://llvm.org/viewvc/llvm-project?rev=359879&view=rev
> Log:
> [CodeGenPrepare] limit overflow intrinsic matching to a single basic block
>
> Using/updating a dominator tree to match math overflow patterns may be very
> expensive in compile-time (because of the way CGP uses a DT), so just handle
> the single-block case.
>
> Also, we were restarting the iterator loops when doing the overflow intrinsic
> transforms by marking the dominator tree for update. That was done to prevent
> iterating over a removed instruction. But we can postpone the deletion using
> the existing "RemovedInsts" structure, and that means we don't need to update
> the DT.
>
> See post-commit thread for rL354298 for more details:
> http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190422/646276.html
>
> Differential Revision: https://reviews.llvm.org/D61075
>
> Modified:
>     llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
>     llvm/trunk/test/CodeGen/X86/cgp-usubo.ll
>     llvm/trunk/test/Transforms/CodeGenPrepare/X86/optimizeSelect-DT.ll
>     llvm/trunk/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll
>
> Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=359879&r1=359878&r2=359879&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
> +++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Fri May  3 06:09:18 2019
> @@ -388,9 +388,9 @@ class TypePromotionTransaction;
>      bool tryToSinkFreeOperands(Instruction *I);
>      bool replaceMathCmpWithIntrinsic(BinaryOperator *BO, CmpInst *Cmp,
>                                       Intrinsic::ID IID);
> -    bool optimizeCmp(CmpInst *Cmp, bool &ModifiedDT);
> -    bool combineToUSubWithOverflow(CmpInst *Cmp, bool &ModifiedDT);
> -    bool combineToUAddWithOverflow(CmpInst *Cmp, bool &ModifiedDT);
> +    bool optimizeCmp(CmpInst *Cmp);
> +    bool combineToUSubWithOverflow(CmpInst *Cmp);
> +    bool combineToUAddWithOverflow(CmpInst *Cmp);
>    };
>
>  } // end anonymous namespace
> @@ -484,9 +484,13 @@ bool CodeGenPrepare::runOnFunction(Funct
>      if (!LargeOffsetGEPMap.empty())
>        MadeChange |= splitLargeGEPOffsets();
>
> -    // Really free removed instructions during promotion.
> -    for (Instruction *I : RemovedInsts)
> +    // Really free instructions removed during promotion or kept around to
> +    // improve efficiency (see comments in overflow intrinsic transforms).
> +    for (Instruction *I : RemovedInsts) {
> +      if (I->getParent())
> +        I->removeFromParent();
>        I->deleteValue();
> +    }
>
>      EverMadeChange |= MadeChange;
>      SeenChainsForSExt.clear();
> @@ -1177,6 +1181,20 @@ static bool OptimizeNoopCopyExpression(C
>  bool CodeGenPrepare::replaceMathCmpWithIntrinsic(BinaryOperator *BO,
>                                                   CmpInst *Cmp,
>                                                   Intrinsic::ID IID) {
> +  if (BO->getParent() != Cmp->getParent()) {
> +    // We used to use a dominator tree here to allow multi-block optimization.
> +    // But that was problematic because:
> +    // 1. It could cause a perf regression by hoisting the math op into the
> +    //    critical path.
> +    // 2. It could cause a perf regression by creating a value that was live
> +    //    across multiple blocks and increasing register pressure.
> +    // 3. Use of a dominator tree could cause large compile-time regression.
> +    //    This is because we recompute the DT on every change in the main CGP
> +    //    run-loop. The recomputing is probably unnecessary in many cases, so if
> +    //    that was fixed, using a DT here would be ok.
> +    return false;
> +  }
> +
>    // We allow matching the canonical IR (add X, C) back to (usubo X, -C).
>    Value *Arg0 = BO->getOperand(0);
>    Value *Arg1 = BO->getOperand(1);
> @@ -1186,45 +1204,28 @@ bool CodeGenPrepare::replaceMathCmpWithI
>      Arg1 = ConstantExpr::getNeg(cast<Constant>(Arg1));
>    }
>
> -  Instruction *InsertPt;
> -  if (BO->hasOneUse() && BO->user_back() == Cmp) {
> -    // If the math is only used by the compare, insert at the compare to keep
> -    // the condition in the same block as its users. (CGP aggressively sinks
> -    // compares to help out SDAG.)
> -    InsertPt = Cmp;
> -  } else {
> -    // The math and compare may be independent instructions. Check dominance to
> -    // determine the insertion point for the intrinsic.
> -    bool MathDominates = getDT(*BO->getFunction()).dominates(BO, Cmp);
> -    if (!MathDominates && !getDT(*BO->getFunction()).dominates(Cmp, BO))
> -      return false;
> -
> -    BasicBlock *MathBB = BO->getParent(), *CmpBB = Cmp->getParent();
> -    if (MathBB != CmpBB) {
> -      // Avoid hoisting an extra op into a dominating block and creating a
> -      // potentially longer critical path.
> -      if (!MathDominates)
> -        return false;
> -      // Check that the insertion doesn't create a value that is live across
> -      // more than two blocks, so to minimise the increase in register pressure.
> -      BasicBlock *Dominator = MathDominates ? MathBB : CmpBB;
> -      BasicBlock *Dominated = MathDominates ? CmpBB : MathBB;
> -      auto Successors = successors(Dominator);
> -      if (llvm::find(Successors, Dominated) == Successors.end())
> -        return false;
> +  // Insert at the first instruction of the pair.
> +  Instruction *InsertPt = nullptr;
> +  for (Instruction &Iter : *Cmp->getParent()) {
> +    if (&Iter == BO || &Iter == Cmp) {
> +      InsertPt = &Iter;
> +      break;
>      }
> -
> -    InsertPt = MathDominates ? cast<Instruction>(BO) : cast<Instruction>(Cmp);
>    }
> +  assert(InsertPt != nullptr && "Parent block did not contain cmp or binop");
>
>    IRBuilder<> Builder(InsertPt);
>    Value *MathOV = Builder.CreateBinaryIntrinsic(IID, Arg0, Arg1);
>    Value *Math = Builder.CreateExtractValue(MathOV, 0, "math");
>    Value *OV = Builder.CreateExtractValue(MathOV, 1, "ov");
> +
> +  // Delay the actual removal/deletion of the binop and compare for efficiency.
> +  // If we delete those now, we would invalidate the instruction iterator and
> +  // trigger dominator tree updates.
>    BO->replaceAllUsesWith(Math);
>    Cmp->replaceAllUsesWith(OV);
> -  BO->eraseFromParent();
> -  Cmp->eraseFromParent();
> +  RemovedInsts.insert(BO);
> +  RemovedInsts.insert(Cmp);
>    return true;
>  }
>
> @@ -1260,8 +1261,7 @@ static bool matchUAddWithOverflowConstan
>
>  /// Try to combine the compare into a call to the llvm.uadd.with.overflow
>  /// intrinsic. Return true if any changes were made.
> -bool CodeGenPrepare::combineToUAddWithOverflow(CmpInst *Cmp,
> -                                               bool &ModifiedDT) {
> +bool CodeGenPrepare::combineToUAddWithOverflow(CmpInst *Cmp) {
>    Value *A, *B;
>    BinaryOperator *Add;
>    if (!match(Cmp, m_UAddWithOverflow(m_Value(A), m_Value(B), m_BinOp(Add))))
> @@ -1281,13 +1281,10 @@ bool CodeGenPrepare::combineToUAddWithOv
>    if (!replaceMathCmpWithIntrinsic(Add, Cmp, Intrinsic::uadd_with_overflow))
>      return false;
>
> -  // Reset callers - do not crash by iterating over a dead instruction.
> -  ModifiedDT = true;
>    return true;
>  }
>
> -bool CodeGenPrepare::combineToUSubWithOverflow(CmpInst *Cmp,
> -                                               bool &ModifiedDT) {
> +bool CodeGenPrepare::combineToUSubWithOverflow(CmpInst *Cmp) {
>    // We are not expecting non-canonical/degenerate code. Just bail out.
>    Value *A = Cmp->getOperand(0), *B = Cmp->getOperand(1);
>    if (isa<Constant>(A) && isa<Constant>(B))
> @@ -1342,8 +1339,6 @@ bool CodeGenPrepare::combineToUSubWithOv
>    if (!replaceMathCmpWithIntrinsic(Sub, Cmp, Intrinsic::usub_with_overflow))
>      return false;
>
> -  // Reset callers - do not crash by iterating over a dead instruction.
> -  ModifiedDT = true;
>    return true;
>  }
>
> @@ -1413,14 +1408,14 @@ static bool sinkCmpExpression(CmpInst *C
>    return MadeChange;
>  }
>
> -bool CodeGenPrepare::optimizeCmp(CmpInst *Cmp, bool &ModifiedDT) {
> +bool CodeGenPrepare::optimizeCmp(CmpInst *Cmp) {
>    if (sinkCmpExpression(Cmp, *TLI))
>      return true;
>
> -  if (combineToUAddWithOverflow(Cmp, ModifiedDT))
> +  if (combineToUAddWithOverflow(Cmp))
>      return true;
>
> -  if (combineToUSubWithOverflow(Cmp, ModifiedDT))
> +  if (combineToUSubWithOverflow(Cmp))
>      return true;
>
>    return false;
> @@ -6945,7 +6940,7 @@ bool CodeGenPrepare::optimizeInst(Instru
>    }
>
>    if (auto *Cmp = dyn_cast<CmpInst>(I))
> -    if (TLI && optimizeCmp(Cmp, ModifiedDT))
> +    if (TLI && optimizeCmp(Cmp))
>        return true;
>
>    if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
>
> Modified: llvm/trunk/test/CodeGen/X86/cgp-usubo.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cgp-usubo.ll?rev=359879&r1=359878&r2=359879&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/cgp-usubo.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/cgp-usubo.ll Fri May  3 06:09:18 2019
> @@ -121,7 +121,7 @@ define i1 @usubo_ne_constant0_op1_i32(i3
>    ret i1 %ov
>  }
>
> -; Verify insertion point for multi-BB.
> +; This used to verify insertion point for multi-BB, but now we just bail out.
>
>  declare void @call(i1)
>
> @@ -131,14 +131,17 @@ define i1 @usubo_ult_sub_dominates_i64(i
>  ; CHECK-NEXT:    testb $1, %cl
>  ; CHECK-NEXT:    je .LBB8_2
>  ; CHECK-NEXT:  # %bb.1: # %t
> -; CHECK-NEXT:    subq %rsi, %rdi
> -; CHECK-NEXT:    setb %al
> -; CHECK-NEXT:    movq %rdi, (%rdx)
> +; CHECK-NEXT:    movq %rdi, %rax
> +; CHECK-NEXT:    subq %rsi, %rax
> +; CHECK-NEXT:    movq %rax, (%rdx)
>  ; CHECK-NEXT:    testb $1, %cl
> -; CHECK-NEXT:    jne .LBB8_3
> +; CHECK-NEXT:    je .LBB8_2
> +; CHECK-NEXT:  # %bb.3: # %end
> +; CHECK-NEXT:    cmpq %rsi, %rdi
> +; CHECK-NEXT:    setb %al
> +; CHECK-NEXT:    retq
>  ; CHECK-NEXT:  .LBB8_2: # %f
>  ; CHECK-NEXT:    movl %ecx, %eax
> -; CHECK-NEXT:  .LBB8_3: # %end
>  ; CHECK-NEXT:    retq
>  entry:
>    br i1 %cond, label %t, label %f
>
> Modified: llvm/trunk/test/Transforms/CodeGenPrepare/X86/optimizeSelect-DT.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CodeGenPrepare/X86/optimizeSelect-DT.ll?rev=359879&r1=359878&r2=359879&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/CodeGenPrepare/X86/optimizeSelect-DT.ll (original)
> +++ llvm/trunk/test/Transforms/CodeGenPrepare/X86/optimizeSelect-DT.ll Fri May  3 06:09:18 2019
> @@ -14,11 +14,10 @@ define i1 @PR41004(i32 %x, i32 %y, i32 %
>  ; CHECK-NEXT:    br label [[SELECT_END]]
>  ; CHECK:       select.end:
>  ; CHECK-NEXT:    [[MUL:%.*]] = phi i32 [ [[REM]], [[SELECT_TRUE_SINK]] ], [ 0, [[ENTRY:%.*]] ]
> -; CHECK-NEXT:    [[TMP0:%.*]] = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 [[T1:%.*]], i32 1)
> -; CHECK-NEXT:    [[MATH:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0
> -; CHECK-NEXT:    [[OV:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1
> -; CHECK-NEXT:    [[ADD:%.*]] = add i32 [[MATH]], [[MUL]]
> -; CHECK-NEXT:    ret i1 [[OV]]
> +; CHECK-NEXT:    [[NEG:%.*]] = add i32 [[T1:%.*]], -1
> +; CHECK-NEXT:    [[ADD:%.*]] = add i32 [[NEG]], [[MUL]]
> +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i32 [[T1]], 0
> +; CHECK-NEXT:    ret i1 [[TOBOOL]]
>  ;
>  entry:
>    %rem = srem i32 %x, 2
>
> Modified: llvm/trunk/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll?rev=359879&r1=359878&r2=359879&view=diff
> ==============================================================================
> --- llvm/trunk/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll (original)
> +++ llvm/trunk/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll Fri May  3 06:09:18 2019
> @@ -47,15 +47,16 @@ define i64 @uaddo3(i64 %a, i64 %b) nounw
>    ret i64 %Q
>  }
>
> +; TODO? CGP sinks the compare before we have a chance to form the overflow intrinsic.
> +
>  define i64 @uaddo4(i64 %a, i64 %b, i1 %c) nounwind ssp {
>  ; CHECK-LABEL: @uaddo4(
>  ; CHECK-NEXT:  entry:
> +; CHECK-NEXT:    [[ADD:%.*]] = add i64 [[B:%.*]], [[A:%.*]]
>  ; CHECK-NEXT:    br i1 [[C:%.*]], label [[NEXT:%.*]], label [[EXIT:%.*]]
>  ; CHECK:       next:
> -; CHECK-NEXT:    [[TMP0:%.*]] = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 [[B:%.*]], i64 [[A:%.*]])
> -; CHECK-NEXT:    [[MATH:%.*]] = extractvalue { i64, i1 } [[TMP0]], 0
> -; CHECK-NEXT:    [[OV:%.*]] = extractvalue { i64, i1 } [[TMP0]], 1
> -; CHECK-NEXT:    [[Q:%.*]] = select i1 [[OV]], i64 [[B]], i64 42
> +; CHECK-NEXT:    [[TMP0:%.*]] = icmp ugt i64 [[B]], [[ADD]]
> +; CHECK-NEXT:    [[Q:%.*]] = select i1 [[TMP0]], i64 [[B]], i64 42
>  ; CHECK-NEXT:    ret i64 [[Q]]
>  ; CHECK:       exit:
>  ; CHECK-NEXT:    ret i64 0
> @@ -362,7 +363,7 @@ define i1 @usubo_ne_constant0_op1_i32(i3
>    ret i1 %ov
>  }
>
> -; Verify insertion point for multi-BB.
> +; This used to verify insertion point for multi-BB, but now we just bail out.
>
>  declare void @call(i1)
>
> @@ -371,15 +372,14 @@ define i1 @usubo_ult_sub_dominates_i64(i
>  ; CHECK-NEXT:  entry:
>  ; CHECK-NEXT:    br i1 [[COND:%.*]], label [[T:%.*]], label [[F:%.*]]
>  ; CHECK:       t:
> -; CHECK-NEXT:    [[TMP0:%.*]] = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 [[X:%.*]], i64 [[Y:%.*]])
> -; CHECK-NEXT:    [[MATH:%.*]] = extractvalue { i64, i1 } [[TMP0]], 0
> -; CHECK-NEXT:    [[OV1:%.*]] = extractvalue { i64, i1 } [[TMP0]], 1
> -; CHECK-NEXT:    store i64 [[MATH]], i64* [[P:%.*]]
> +; CHECK-NEXT:    [[S:%.*]] = sub i64 [[X:%.*]], [[Y:%.*]]
> +; CHECK-NEXT:    store i64 [[S]], i64* [[P:%.*]]
>  ; CHECK-NEXT:    br i1 [[COND]], label [[END:%.*]], label [[F]]
>  ; CHECK:       f:
>  ; CHECK-NEXT:    ret i1 [[COND]]
>  ; CHECK:       end:
> -; CHECK-NEXT:    ret i1 [[OV1]]
> +; CHECK-NEXT:    [[OV:%.*]] = icmp ult i64 [[X]], [[Y]]
> +; CHECK-NEXT:    ret i1 [[OV]]
>  ;
>  entry:
>    br i1 %cond, label %t, label %f
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list