xref: /minix3/external/bsd/llvm/dist/llvm/test/CodeGen/X86/i128-mul.ll (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc; RUN: llc < %s -march=x86-64 -mcpu=corei7 | FileCheck %s
2*f4a2713aSLionel Sambuc; PR1198
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambucdefine i64 @foo(i64 %x, i64 %y) {
5*f4a2713aSLionel Sambuc        %tmp0 = zext i64 %x to i128
6*f4a2713aSLionel Sambuc        %tmp1 = zext i64 %y to i128
7*f4a2713aSLionel Sambuc        %tmp2 = mul i128 %tmp0, %tmp1
8*f4a2713aSLionel Sambuc        %tmp7 = zext i32 64 to i128
9*f4a2713aSLionel Sambuc        %tmp3 = lshr i128 %tmp2, %tmp7
10*f4a2713aSLionel Sambuc        %tmp4 = trunc i128 %tmp3 to i64
11*f4a2713aSLionel Sambuc        ret i64 %tmp4
12*f4a2713aSLionel Sambuc}
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambuc; <rdar://problem/14096009> superfluous multiply by high part of
15*f4a2713aSLionel Sambuc; zero-extended value.
16*f4a2713aSLionel Sambuc; CHECK: @mul1
17*f4a2713aSLionel Sambuc; CHECK-NOT: imulq
18*f4a2713aSLionel Sambuc; CHECK: mulq
19*f4a2713aSLionel Sambuc; CHECK-NOT: imulq
20*f4a2713aSLionel Sambucdefine i64 @mul1(i64 %n, i64* nocapture %z, i64* nocapture %x, i64 %y) {
21*f4a2713aSLionel Sambucentry:
22*f4a2713aSLionel Sambuc  %conv = zext i64 %y to i128
23*f4a2713aSLionel Sambuc  %cmp11 = icmp eq i64 %n, 0
24*f4a2713aSLionel Sambuc  br i1 %cmp11, label %for.end, label %for.body
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel Sambucfor.body:                                         ; preds = %entry, %for.body
27*f4a2713aSLionel Sambuc  %carry.013 = phi i64 [ %conv6, %for.body ], [ 0, %entry ]
28*f4a2713aSLionel Sambuc  %i.012 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
29*f4a2713aSLionel Sambuc  %arrayidx = getelementptr inbounds i64* %x, i64 %i.012
30*f4a2713aSLionel Sambuc  %0 = load i64* %arrayidx, align 8
31*f4a2713aSLionel Sambuc  %conv2 = zext i64 %0 to i128
32*f4a2713aSLionel Sambuc  %mul = mul i128 %conv2, %conv
33*f4a2713aSLionel Sambuc  %conv3 = zext i64 %carry.013 to i128
34*f4a2713aSLionel Sambuc  %add = add i128 %mul, %conv3
35*f4a2713aSLionel Sambuc  %conv4 = trunc i128 %add to i64
36*f4a2713aSLionel Sambuc  %arrayidx5 = getelementptr inbounds i64* %z, i64 %i.012
37*f4a2713aSLionel Sambuc  store i64 %conv4, i64* %arrayidx5, align 8
38*f4a2713aSLionel Sambuc  %shr = lshr i128 %add, 64
39*f4a2713aSLionel Sambuc  %conv6 = trunc i128 %shr to i64
40*f4a2713aSLionel Sambuc  %inc = add i64 %i.012, 1
41*f4a2713aSLionel Sambuc  %exitcond = icmp eq i64 %inc, %n
42*f4a2713aSLionel Sambuc  br i1 %exitcond, label %for.end, label %for.body
43*f4a2713aSLionel Sambuc
44*f4a2713aSLionel Sambucfor.end:                                          ; preds = %for.body, %entry
45*f4a2713aSLionel Sambuc  ret i64 0
46*f4a2713aSLionel Sambuc}
47