mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
Fix another infinite loop in InstCombine
Summary: InstCombine infinite-loops for the testcase added It is because InstCombine is generating instructions that can be optimized by itself. Fix by not optimizing frem if the optimized type is the same as original type. rdar://problem/19150820 Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D6634 llvm-svn: 224097
This commit is contained in:
parent
c1a6f36235
commit
896d3dd47b
@ -1269,16 +1269,19 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) {
|
|||||||
// type of OpI doesn't enter into things at all. We simply evaluate
|
// type of OpI doesn't enter into things at all. We simply evaluate
|
||||||
// in whichever source type is larger, then convert to the
|
// in whichever source type is larger, then convert to the
|
||||||
// destination type.
|
// destination type.
|
||||||
if (LHSWidth < SrcWidth)
|
if (SrcWidth != OpWidth) {
|
||||||
LHSOrig = Builder->CreateFPExt(LHSOrig, RHSOrig->getType());
|
if (LHSWidth < SrcWidth)
|
||||||
else if (RHSWidth <= SrcWidth)
|
LHSOrig = Builder->CreateFPExt(LHSOrig, RHSOrig->getType());
|
||||||
RHSOrig = Builder->CreateFPExt(RHSOrig, LHSOrig->getType());
|
else if (RHSWidth <= SrcWidth)
|
||||||
if (LHSOrig != OpI->getOperand(0) || RHSOrig != OpI->getOperand(1)) {
|
RHSOrig = Builder->CreateFPExt(RHSOrig, LHSOrig->getType());
|
||||||
Value *ExactResult = Builder->CreateFRem(LHSOrig, RHSOrig);
|
if (LHSOrig != OpI->getOperand(0) || RHSOrig != OpI->getOperand(1)) {
|
||||||
if (Instruction *RI = dyn_cast<Instruction>(ExactResult))
|
Value *ExactResult = Builder->CreateFRem(LHSOrig, RHSOrig);
|
||||||
RI->copyFastMathFlags(OpI);
|
if (Instruction *RI = dyn_cast<Instruction>(ExactResult))
|
||||||
return CastInst::CreateFPCast(ExactResult, CI.getType());
|
RI->copyFastMathFlags(OpI);
|
||||||
|
return CastInst::CreateFPCast(ExactResult, CI.getType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (fptrunc (fneg x)) -> (fneg (fptrunc x))
|
// (fptrunc (fneg x)) -> (fneg (fptrunc x))
|
||||||
|
@ -73,3 +73,15 @@ define float @test7(double %V) {
|
|||||||
; CHECK-NEXT: %[[trunc:.*]] = fptrunc double %frem to float
|
; CHECK-NEXT: %[[trunc:.*]] = fptrunc double %frem to float
|
||||||
; CHECK-NEXT: ret float %trunc
|
; CHECK-NEXT: ret float %trunc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define float @test8(float %V) {
|
||||||
|
%fext = fpext float %V to double
|
||||||
|
%frem = frem double %fext, 1.000000e-01
|
||||||
|
%trunc = fptrunc double %frem to float
|
||||||
|
ret float %trunc
|
||||||
|
; CHECK-LABEL: @test8
|
||||||
|
; CHECK-NEXT: %[[fext:.*]] = fpext float %V to double
|
||||||
|
; CHECK-NEXT: %[[frem:.*]] = frem double %fext, 1.000000e-01
|
||||||
|
; CHECK-NEXT: %[[trunc:.*]] = fptrunc double %frem to float
|
||||||
|
; CHECK-NEXT: ret float %trunc
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user