summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstSimplify/call.ll
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-12-28 14:23:29 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-12-28 14:23:29 +0000
commitf6182155f62b49c073d161c25f2468b8ca63869a (patch)
treeb0e95137fc2e85d7fb954582045e44719f5feabe /llvm/test/Transforms/InstSimplify/call.ll
parent576127d90e242b8a6de7710794cdc4c146891229 (diff)
downloadbcm5719-llvm-f6182155f62b49c073d161c25f2468b8ca63869a.tar.gz
bcm5719-llvm-f6182155f62b49c073d161c25f2468b8ca63869a.zip
Teach instsimplify to use the constant folder where appropriate for
constant folding calls. Add the initial tests for this which show that now instsimplify can simplify blindingly obvious code patterns expressed with both intrinsics and library calls. llvm-svn: 171194
Diffstat (limited to 'llvm/test/Transforms/InstSimplify/call.ll')
-rw-r--r--llvm/test/Transforms/InstSimplify/call.ll52
1 files changed, 52 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/call.ll b/llvm/test/Transforms/InstSimplify/call.ll
new file mode 100644
index 00000000000..1a8d0c25bd2
--- /dev/null
+++ b/llvm/test/Transforms/InstSimplify/call.ll
@@ -0,0 +1,52 @@
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+declare {i8, i1} @llvm.uadd.with.overflow.i8(i8 %a, i8 %b)
+
+define i1 @test_uadd1() {
+; CHECK: @test_uadd1
+ %x = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 254, i8 3)
+ %overflow = extractvalue {i8, i1} %x, 1
+ ret i1 %overflow
+; CHECK-NEXT: ret i1 true
+}
+
+define i8 @test_uadd2() {
+; CHECK: @test_uadd2
+ %x = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 254, i8 44)
+ %result = extractvalue {i8, i1} %x, 0
+ ret i8 %result
+; CHECK-NEXT: ret i8 42
+}
+
+declare i256 @llvm.cttz.i256(i256 %src, i1 %is_zero_undef)
+
+define i256 @test_cttz() {
+; CHECK: @test_cttz
+ %x = call i256 @llvm.cttz.i256(i256 10, i1 false)
+ ret i256 %x
+; CHECK-NEXT: ret i256 1
+}
+
+declare i256 @llvm.ctpop.i256(i256 %src)
+
+define i256 @test_ctpop() {
+; CHECK: @test_ctpop
+ %x = call i256 @llvm.ctpop.i256(i256 10)
+ ret i256 %x
+; CHECK-NEXT: ret i256 2
+}
+
+; Test a non-intrinsic that we know about as a library call.
+declare float @fabs(float %x)
+
+define float @test_fabs_libcall() {
+; CHECK: @test_fabs_libcall
+
+ %x = call float @fabs(float -42.0)
+; This is still a real function call, so instsimplify won't nuke it -- other
+; passes have to do that.
+; CHECK-NEXT: call float @fabs
+
+ ret float %x
+; CHECK-NEXT: ret float 4.2{{0+}}e+01
+}
OpenPOWER on IntegriCloud