diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-01-14 21:44:30 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-01-14 21:44:30 +0000 |
commit | a2b5c4ba6ab5d904c460123cbb6d26874d28039c (patch) | |
tree | b0caa867d83d14dcdde578b43dfa8007eb8f8d7c /clang/test/CodeGen/builtins-multiprecision.c | |
parent | 77ca8b83a98b7665e0c5dd37b6bafd999d52e975 (diff) | |
download | bcm5719-llvm-a2b5c4ba6ab5d904c460123cbb6d26874d28039c.tar.gz bcm5719-llvm-a2b5c4ba6ab5d904c460123cbb6d26874d28039c.zip |
Multiprecision subtraction builtins.
We lower these into 2x chained usub.with.overflow intrinsics.
llvm-svn: 172476
Diffstat (limited to 'clang/test/CodeGen/builtins-multiprecision.c')
-rw-r--r-- | clang/test/CodeGen/builtins-multiprecision.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/clang/test/CodeGen/builtins-multiprecision.c b/clang/test/CodeGen/builtins-multiprecision.c index 82239d4650a..172f683de3b 100644 --- a/clang/test/CodeGen/builtins-multiprecision.c +++ b/clang/test/CodeGen/builtins-multiprecision.c @@ -75,3 +75,76 @@ unsigned long long test_addcll(unsigned long long x, unsigned long long y, return carryout; } + +unsigned short test_subcs(unsigned short x, unsigned short y, + unsigned short carryin, unsigned short *z) { + // CHECK: @test_subcs + // CHECK: %{{.+}} = {{.*}} call { i16, i1 } @llvm.usub.with.overflow.i16(i16 %x, i16 %y) + // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 1 + // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 0 + // CHECK: %{{.+}} = {{.*}} call { i16, i1 } @llvm.usub.with.overflow.i16(i16 %{{.+}}, i16 %carryin) + // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 1 + // CHECK: %{{.+}} = extractvalue { i16, i1 } %{{.+}}, 0 + // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}} + // CHECK: %{{.+}} = zext i1 %{{.+}} to i16 + // CHECK: store i16 %{{.+}}, i16* %z, align 2 + + unsigned short carryout; + *z = __builtin_subcs(x, y, carryin, &carryout); + + return carryout; +} + +unsigned test_subc(unsigned x, unsigned y, unsigned carryin, unsigned *z) { + // CHECK: @test_subc + // CHECK: %{{.+}} = {{.*}} call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %x, i32 %y) + // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 1 + // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 0 + // CHECK: %{{.+}} = {{.*}} call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %{{.+}}, i32 %carryin) + // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 1 + // CHECK: %{{.+}} = extractvalue { i32, i1 } %{{.+}}, 0 + // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}} + // CHECK: %{{.+}} = zext i1 %{{.+}} to i32 + // CHECK: store i32 %{{.+}}, i32* %z, align 4 + unsigned carryout; + *z = __builtin_subc(x, y, carryin, &carryout); + + return carryout; +} + +unsigned long test_subcl(unsigned long x, unsigned long y, + unsigned long carryin, unsigned long *z) { + // CHECK: @test_subcl([[UL:i32|i64]] %x + // CHECK: %{{.+}} = {{.*}} call { [[UL]], i1 } @llvm.usub.with.overflow.[[UL]]([[UL]] %x, [[UL]] %y) + // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 1 + // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 0 + // CHECK: %{{.+}} = {{.*}} call { [[UL]], i1 } @llvm.usub.with.overflow.[[UL]]([[UL]] %{{.+}}, [[UL]] %carryin) + // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 1 + // CHECK: %{{.+}} = extractvalue { [[UL]], i1 } %{{.+}}, 0 + // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}} + // CHECK: %{{.+}} = zext i1 %{{.+}} to [[UL]] + // CHECK: store [[UL]] %{{.+}}, [[UL]]* %z + unsigned long carryout; + *z = __builtin_subcl(x, y, carryin, &carryout); + + return carryout; +} + +unsigned long long test_subcll(unsigned long long x, unsigned long long y, + unsigned long long carryin, + unsigned long long *z) { + // CHECK: @test_subcll + // CHECK: %{{.+}} = {{.*}} call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %x, i64 %y) + // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 1 + // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 0 + // CHECK: %{{.+}} = {{.*}} call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %{{.+}}, i64 %carryin) + // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 1 + // CHECK: %{{.+}} = extractvalue { i64, i1 } %{{.+}}, 0 + // CHECK: %{{.+}} = or i1 %{{.+}}, %{{.+}} + // CHECK: %{{.+}} = zext i1 %{{.+}} to i64 + // CHECK: store i64 %{{.+}}, i64* %z + unsigned long long carryout; + *z = __builtin_subcll(x, y, carryin, &carryout); + + return carryout; +} |