Index: lib/CodeGen/CodeGenPrepare.cpp =================================================================== --- lib/CodeGen/CodeGenPrepare.cpp +++ lib/CodeGen/CodeGenPrepare.cpp @@ -6926,6 +6926,14 @@ if (InsertedInsts.count(I)) return false; + // Drop all llvm.assume calls + if (match(I, m_Intrinsic())) { + Value *Arg = I->getOperand(0); + I->eraseFromParent(); + RecursivelyDeleteTriviallyDeadInstructions(Arg); + return true; + } + // TODO: Move into the switch on opcode below here. if (PHINode *P = dyn_cast(I)) { // It is possible for very late stage optimizations (such as SimplifyCFG) Index: test/Transforms/CodeGenPrepare/assume.ll =================================================================== --- test/Transforms/CodeGenPrepare/assume.ll +++ test/Transforms/CodeGenPrepare/assume.ll @@ -0,0 +1,17 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -codegenprepare -S %s | FileCheck %s + +declare i32 @foo() +declare void @llvm.assume(i1) + +define void @bar() { +; CHECK-LABEL: @bar( +; CHECK-NEXT: ret void +; + %call = tail call i32 @foo() #0 + %cmp = icmp eq i32 %call, 1 + tail call void @llvm.assume(i1 %cmp) + ret void +} + +attributes #0 = { nounwind readnone }