diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index bf32996d96e..6e0587ddd09 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2592,14 +2592,17 @@ Instruction *InstCombiner::visitReturnInst(ReturnInst &RI) { Value *ResultOp = RI.getOperand(0); Type *VTy = ResultOp->getType(); - if (!VTy->isIntegerTy()) + if (!VTy->isIntegerTy() || isa(ResultOp)) return nullptr; // There might be assume intrinsics dominating this return that completely // determine the value. If so, constant fold it. KnownBits Known = computeKnownBits(ResultOp, 0, &RI); - if (Known.isConstant()) + if (Known.isConstant()) { + Worklist.AddValue(ResultOp); RI.setOperand(0, Constant::getIntegerValue(VTy, Known.getConstant())); + return &RI; + } return nullptr; } diff --git a/test/Transforms/InstCombine/assume.ll b/test/Transforms/InstCombine/assume.ll index a9bdce7f6a0..2d9f2a616e7 100644 --- a/test/Transforms/InstCombine/assume.ll +++ b/test/Transforms/InstCombine/assume.ll @@ -190,16 +190,10 @@ entry: } define i32 @icmp1(i32 %a) #0 { -; EXPENSIVE-ON-LABEL: @icmp1( -; EXPENSIVE-ON-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A:%.*]], 5 -; EXPENSIVE-ON-NEXT: tail call void @llvm.assume(i1 [[CMP]]) -; EXPENSIVE-ON-NEXT: ret i32 1 -; -; EXPENSIVE-OFF-LABEL: @icmp1( -; EXPENSIVE-OFF-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A:%.*]], 5 -; EXPENSIVE-OFF-NEXT: tail call void @llvm.assume(i1 [[CMP]]) -; EXPENSIVE-OFF-NEXT: [[CONV:%.*]] = zext i1 [[CMP]] to i32 -; EXPENSIVE-OFF-NEXT: ret i32 1 +; CHECK-LABEL: @icmp1( +; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[A:%.*]], 5 +; CHECK-NEXT: tail call void @llvm.assume(i1 [[CMP]]) +; CHECK-NEXT: ret i32 1 ; %cmp = icmp sgt i32 %a, 5 tail call void @llvm.assume(i1 %cmp)