diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-05 05:26:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-05 05:26:04 +0000 |
commit | e65cd40ab99c3bd43dc997873e500643d012bbad (patch) | |
tree | 766f41925f54eab14308a1c17a72d1df67b4f012 /test/Transforms | |
parent | d0806a1519f3bc450d2dea3e6f22db73fc797e4c (diff) | |
download | external_llvm-e65cd40ab99c3bd43dc997873e500643d012bbad.zip external_llvm-e65cd40ab99c3bd43dc997873e500643d012bbad.tar.gz external_llvm-e65cd40ab99c3bd43dc997873e500643d012bbad.tar.bz2 |
teach the optimizer how to constant fold uadd/usub intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@83295 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/ConstProp/overflow-ops.ll | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/Transforms/ConstProp/overflow-ops.ll b/test/Transforms/ConstProp/overflow-ops.ll new file mode 100644 index 0000000..52d5921 --- /dev/null +++ b/test/Transforms/ConstProp/overflow-ops.ll @@ -0,0 +1,53 @@ +; RUN: opt < %s -constprop -S | FileCheck %s + +%i8i1 = type {i8, i1} + +;;----------------------------- +;; uadd +;;----------------------------- + +define {i8, i1} @uadd_1() nounwind { +entry: + %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 42, i8 100) + ret {i8, i1} %t + +; CHECK: @uadd_1 +; CHECK: ret %i8i1 { i8 -114, i1 false } +} + +define {i8, i1} @uadd_2() nounwind { +entry: + %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 120) + ret {i8, i1} %t + +; CHECK: @uadd_2 +; CHECK: ret %i8i1 { i8 6, i1 true } +} + + +;;----------------------------- +;; usub +;;----------------------------- + +define {i8, i1} @usub_1() nounwind { +entry: + %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 2) + ret {i8, i1} %t + +; CHECK: @usub_1 +; CHECK: ret %i8i1 { i8 2, i1 false } +} + +define {i8, i1} @usub_2() nounwind { +entry: + %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 6) + ret {i8, i1} %t + +; CHECK: @usub_2 +; CHECK: ret %i8i1 { i8 -2, i1 true } +} + + + +declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8) +declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8) |