summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/builtins-overflow.c
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-12-18 21:05:03 +0000
committerVedant Kumar <vsk@apple.com>2018-12-18 21:05:03 +0000
commit77dfca88b2a3bed8a0f9961cc5d06c8382c9b926 (patch)
tree52a9e83a367b0fdfa187b3a19b77dbbcbd5a269a /clang/test/CodeGen/builtins-overflow.c
parent7b3db0e4fd99967fc66431f60c7c6bafd99b104a (diff)
downloadbcm5719-llvm-77dfca88b2a3bed8a0f9961cc5d06c8382c9b926.tar.gz
bcm5719-llvm-77dfca88b2a3bed8a0f9961cc5d06c8382c9b926.zip
[CodeGen] Handle mixed-width ops in mixed-sign mul-with-overflow lowering
The special lowering for __builtin_mul_overflow introduced in r320902 fixed an ICE seen when passing mixed-sign operands to the builtin. This patch extends the special lowering to cover mixed-width, mixed-sign operands. In a few common scenarios, calls to muloti4 will no longer be emitted. This should address the latest comments in PR34920 and work around the link failure seen in: https://bugzilla.redhat.com/show_bug.cgi?id=1657544 Testing: - check-clang - A/B output comparison with: https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081 Differential Revision: https://reviews.llvm.org/D55843 llvm-svn: 349542
Diffstat (limited to 'clang/test/CodeGen/builtins-overflow.c')
-rw-r--r--clang/test/CodeGen/builtins-overflow.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/test/CodeGen/builtins-overflow.c b/clang/test/CodeGen/builtins-overflow.c
index 57f90eb66a5..79a3186b745 100644
--- a/clang/test/CodeGen/builtins-overflow.c
+++ b/clang/test/CodeGen/builtins-overflow.c
@@ -339,6 +339,27 @@ long long test_smulll_overflow(long long x, long long y) {
return result;
}
+int test_mixed_sign_mul_overflow_sext_signed_op(int x, unsigned long long y) {
+// CHECK: @test_mixed_sign_mul_overflow_sext_signed_op
+// CHECK: [[SignedOp:%.*]] = sext i32 %0 to i64
+// CHECK: [[IsNeg:%.*]] = icmp slt i64 [[SignedOp]], 0
+ int result;
+ if (__builtin_mul_overflow(x, y, &result))
+ return LongErrorCode;
+ return result;
+}
+
+int test_mixed_sign_mul_overflow_zext_unsigned_op(long long x, unsigned y) {
+// CHECK: @test_mixed_sign_mul_overflow_zext_unsigned_op
+// CHECK: [[UnsignedOp:%.*]] = zext i32 %1 to i64
+// CHECK: [[IsNeg:%.*]] = icmp slt i64 %0, 0
+// CHECK: @llvm.umul.with.overflow.i64({{.*}}, i64 [[UnsignedOp]])
+ int result;
+ if (__builtin_mul_overflow(x, y, &result))
+ return LongErrorCode;
+ return result;
+}
+
int test_mixed_sign_mull_overflow(int x, unsigned y) {
// CHECK: @test_mixed_sign_mull_overflow
// CHECK: [[IsNeg:%.*]] = icmp slt i32 [[Op1:%.*]], 0
OpenPOWER on IntegriCloud