diff options
author | Owen Anderson <resistor@mac.com> | 2013-01-10 22:06:52 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2013-01-10 22:06:52 +0000 |
commit | dbf0ca523db58931e2d1a9141cfbcbfdcf5eebc2 (patch) | |
tree | fa657d6ac20d98a1e7705a30486a8aec7bc29c9f /llvm/test/Transforms | |
parent | 929cf5615f54f9bdacc88a8b76a09305c9aedbb9 (diff) | |
download | bcm5719-llvm-dbf0ca523db58931e2d1a9141cfbcbfdcf5eebc2.tar.gz bcm5719-llvm-dbf0ca523db58931e2d1a9141cfbcbfdcf5eebc2.zip |
Teach InstCombine to hoist FABS and FNEG through FPTRUNC instructions. The application of these operations commutes with the truncation, so we should prefer to do them in the smallest size we can, to save register space, use smaller constant pool entries, etc.
llvm-svn: 172117
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r-- | llvm/test/Transforms/InstCombine/fpcast.ll | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fpcast.ll b/llvm/test/Transforms/InstCombine/fpcast.ll index bc6aa0a6891..09f053289dc 100644 --- a/llvm/test/Transforms/InstCombine/fpcast.ll +++ b/llvm/test/Transforms/InstCombine/fpcast.ll @@ -13,3 +13,22 @@ define i8 @test2() { ; CHECK: ret i8 -1 } +; CHECK: test3 +define half @test3(float %a) { +; CHECK: fptrunc +; CHECK: llvm.fabs.f16 + %b = call float @llvm.fabs.f32(float %a) + %c = fptrunc float %b to half + ret half %c +} + +; CHECK: test4 +define half @test4(float %a) { +; CHECK: fptrunc +; CHECK: fsub + %b = fsub float -0.0, %a + %c = fptrunc float %b to half + ret half %c +} + +declare float @llvm.fabs.f32(float) nounwind readonly |