diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -159,7 +159,6 @@ Instruction *visitFenceInst(FenceInst &FI); Instruction *visitSwitchInst(SwitchInst &SI); Instruction *visitReturnInst(ReturnInst &RI); - Instruction *visitUnreachableInst(UnreachableInst &I); Instruction * foldAggregateConstructionIntoAggregateReuse(InsertValueInst &OrigIVI); Instruction *visitInsertValueInst(InsertValueInst &IV); diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2798,19 +2798,6 @@ return nullptr; } -Instruction *InstCombinerImpl::visitUnreachableInst(UnreachableInst &I) { - // Try to remove the previous instruction if it must lead to unreachable. - // This includes instructions like stores and "llvm.assume" that may not get - // removed by simple dead code elimination. - Instruction *Prev = I.getPrevNonDebugInstruction(); - if (Prev && !Prev->isEHPad() && - isGuaranteedToTransferExecutionToSuccessor(Prev)) { - eraseInstFromFunction(*Prev); - return &I; - } - return nullptr; -} - Instruction *InstCombinerImpl::visitUnconditionalBranchInst(BranchInst &BI) { assert(BI.isUnconditional() && "Only for unconditional branches."); diff --git a/llvm/test/Transforms/InstCombine/assume.ll b/llvm/test/Transforms/InstCombine/assume.ll --- a/llvm/test/Transforms/InstCombine/assume.ll +++ b/llvm/test/Transforms/InstCombine/assume.ll @@ -1,5 +1,5 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt < %s -instcombine -S -instcombine-infinite-loop-threshold=2 | FileCheck %s +; RUN: opt < %s -instcombine -S | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @@ -543,6 +543,7 @@ define void @PR36270(i32 %b) { ; CHECK-LABEL: @PR36270( +; CHECK-NEXT: tail call void @llvm.assume(i1 false) ; CHECK-NEXT: unreachable ; %B7 = xor i32 -1, 2147483647 @@ -572,6 +573,8 @@ ; CHECK-NEXT: tail call void @llvm.assume(i1 [[CMP3]]) ; CHECK-NEXT: br label [[EXIT]] ; CHECK: exit: +; CHECK-NEXT: [[CMP4:%.*]] = icmp eq i32 [[X]], 2 +; CHECK-NEXT: tail call void @llvm.assume(i1 [[CMP4]]) ; CHECK-NEXT: unreachable ; entry: @@ -609,6 +612,11 @@ ; CHECK-NEXT: tail call void @llvm.assume(i1 [[CMP3]]) ; CHECK-NEXT: br label [[EXIT]] ; CHECK: exit: +; CHECK-NEXT: [[CMP4:%.*]] = icmp eq i32 [[X]], 2 +; CHECK-NEXT: tail call void @llvm.assume(i1 [[CMP4]]) +; CHECK-NEXT: [[CMP5:%.*]] = icmp ugt i32 [[Y]], 42 +; CHECK-NEXT: tail call void @llvm.assume(i1 [[CMP5]]) +; CHECK-NEXT: store i32 [[X]], i32* [[P:%.*]], align 4 ; CHECK-NEXT: unreachable ; entry: diff --git a/llvm/test/Transforms/InstCombine/pr33689_same_bitwidth.ll b/llvm/test/Transforms/InstCombine/pr33689_same_bitwidth.ll --- a/llvm/test/Transforms/InstCombine/pr33689_same_bitwidth.ll +++ b/llvm/test/Transforms/InstCombine/pr33689_same_bitwidth.ll @@ -17,6 +17,8 @@ ; CHECK-NEXT: [[T12_SUB:%.*]] = getelementptr inbounds [2 x i32], [2 x i32]* [[T12]], i16 0, i16 0 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[BB1:%.*]], label [[BB2:%.*]] ; CHECK: bb1: +; CHECK-NEXT: [[T8:%.*]] = ptrtoint [2 x i32]* [[T12]] to i16 +; CHECK-NEXT: store i16 [[T8]], i16* @a, align 2 ; CHECK-NEXT: unreachable ; CHECK: bb2: ; CHECK-NEXT: [[T9:%.*]] = load i16*, i16** @b, align 2