mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[InstCombine] Fix worklist management in return combine
There are two related bugs here: First, we don't add the operand we're replacing to the worklist, which means it may not get DCEd (see test change). Second, usually this would just get picked up in the next iteration, but we also do not report the instruction as changed. This means that we do not get that extra instcombine iteration, and more importantly, may break the pass pipeline, as the function is not marked as changed. Differential Revision: https://reviews.llvm.org/D72864
This commit is contained in:
parent
d31158ae0f
commit
50ac6afd84
@ -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<Constant>(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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user