diff options
author | Eric Christopher <echristo@apple.com> | 2011-06-17 20:41:29 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2011-06-17 20:41:29 +0000 |
commit | 362fee90b9a1d64ac091755466caf6a94ade22eb (patch) | |
tree | 447311a20ba09a9f5ffb810b8c3f902e98be4df6 /test | |
parent | 916a94b870042772568fca7995cf45aef7a6e333 (diff) | |
download | llvm-362fee90b9a1d64ac091755466caf6a94ade22eb.tar.gz llvm-362fee90b9a1d64ac091755466caf6a94ade22eb.tar.bz2 llvm-362fee90b9a1d64ac091755466caf6a94ade22eb.tar.xz |
Lower multiply with overflow checking to __mulo<mode>
calls if we haven't been able to lower them any
other way.
Fixes rdar://9090077 and rdar://9210061
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133288 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/X86/muloti.ll | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/CodeGen/X86/muloti.ll b/test/CodeGen/X86/muloti.ll new file mode 100644 index 0000000000..eb9b6460cd --- /dev/null +++ b/test/CodeGen/X86/muloti.ll @@ -0,0 +1,38 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s +%0 = type { i64, i64 } +%1 = type { i128, i1 } + +@.str = private unnamed_addr constant [11 x i8] c"%llx %llx\0A\00", align 1 + +define %0 @x(i64 %a.coerce0, i64 %a.coerce1, i64 %b.coerce0, i64 %b.coerce1) nounwind uwtable ssp { +entry: + %tmp16 = zext i64 %a.coerce0 to i128 + %tmp11 = zext i64 %a.coerce1 to i128 + %tmp12 = shl nuw i128 %tmp11, 64 + %ins14 = or i128 %tmp12, %tmp16 + %tmp6 = zext i64 %b.coerce0 to i128 + %tmp3 = zext i64 %b.coerce1 to i128 + %tmp4 = shl nuw i128 %tmp3, 64 + %ins = or i128 %tmp4, %tmp6 + %0 = tail call %1 @llvm.smul.with.overflow.i128(i128 %ins14, i128 %ins) +; CHECK: callq ___muloti4 + %1 = extractvalue %1 %0, 0 + %2 = extractvalue %1 %0, 1 + br i1 %2, label %overflow, label %nooverflow + +overflow: ; preds = %entry + tail call void @llvm.trap() + unreachable + +nooverflow: ; preds = %entry + %tmp20 = trunc i128 %1 to i64 + %tmp21 = insertvalue %0 undef, i64 %tmp20, 0 + %tmp22 = lshr i128 %1, 64 + %tmp23 = trunc i128 %tmp22 to i64 + %tmp24 = insertvalue %0 %tmp21, i64 %tmp23, 1 + ret %0 %tmp24 +} + +declare %1 @llvm.smul.with.overflow.i128(i128, i128) nounwind readnone + +declare void @llvm.trap() nounwind |