diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2014-11-18 21:30:02 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2014-11-18 21:30:02 +0000 |
| commit | b32eaddf11a65d52b41935207d69d6ba1564228d (patch) | |
| tree | 2b9828d1f72039c0539934011b4e0be761ba277d /llvm | |
| parent | ef2ad33e8a17c0b5db2d9eda4848c2773b5500a7 (diff) | |
| download | bcm5719-llvm-b32eaddf11a65d52b41935207d69d6ba1564228d.tar.gz bcm5719-llvm-b32eaddf11a65d52b41935207d69d6ba1564228d.zip | |
Revert "Revert r222040 because of bot failure."
This reverts commit r222203, reverting r222040 didn't end up turning the
bot green.
llvm-svn: 222261
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 15 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fpcast.ll | 10 |
2 files changed, 19 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index b41cdc65202..a0570f7ebd4 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1269,14 +1269,17 @@ Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) { // type of OpI doesn't enter into things at all. We simply evaluate // in whichever source type is larger, then convert to the // destination type. + Value *NewLHS = LHSOrig, *NewRHS = RHSOrig; if (LHSWidth < SrcWidth) - LHSOrig = Builder->CreateFPExt(LHSOrig, RHSOrig->getType()); + NewLHS = Builder->CreateFPExt(NewLHS, RHSOrig->getType()); else if (RHSWidth <= SrcWidth) - RHSOrig = Builder->CreateFPExt(RHSOrig, LHSOrig->getType()); - Value *ExactResult = Builder->CreateFRem(LHSOrig, RHSOrig); - if (Instruction *RI = dyn_cast<Instruction>(ExactResult)) - RI->copyFastMathFlags(OpI); - return CastInst::CreateFPCast(ExactResult, CI.getType()); + NewRHS = Builder->CreateFPExt(NewRHS, LHSOrig->getType()); + if (NewLHS != LHSOrig || NewRHS != RHSOrig) { + Value *ExactResult = Builder->CreateFRem(NewLHS, NewRHS); + if (Instruction *RI = dyn_cast<Instruction>(ExactResult)) + RI->copyFastMathFlags(OpI); + return CastInst::CreateFPCast(ExactResult, CI.getType()); + } } // (fptrunc (fneg x)) -> (fneg (fptrunc x)) diff --git a/llvm/test/Transforms/InstCombine/fpcast.ll b/llvm/test/Transforms/InstCombine/fpcast.ll index 9be66fd42c6..c4c8578198b 100644 --- a/llvm/test/Transforms/InstCombine/fpcast.ll +++ b/llvm/test/Transforms/InstCombine/fpcast.ll @@ -53,3 +53,13 @@ define half @test5(float %a, float %b, float %c) { } declare float @llvm.fabs.f32(float) nounwind readonly + +define <1 x float> @test6(<1 x double> %V) { + %frem = frem <1 x double> %V, %V + %trunc = fptrunc <1 x double> %frem to <1 x float> + ret <1 x float> %trunc +; CHECK-LABEL: @test6 +; CHECK-NEXT: %[[frem:.*]] = frem <1 x double> %V, %V +; CHECK-NEXT: %[[trunc:.*]] = fptrunc <1 x double> %[[frem]] to <1 x float> +; CHECK-NEXT: ret <1 x float> %trunc +} |

