blob: 874f43dd398f11ae3bc6a86d4d33312d8aa86623 [file] [log] [blame]
Ulrich Weigand9e3577f2013-05-06 16:17:29 +00001; Test high-part i32->i64 multiplications.
2;
3; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5; We don't provide *MUL_LOHI or MULH* for the patterns in this file,
6; but they should at least still work.
7
8; Check zero-extended multiplication in which only the high part is used.
9define i32 @f1(i32 %a, i32 %b) {
Stephen Lind24ab202013-07-14 06:24:09 +000010; CHECK-LABEL: f1:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000011; CHECK: msgr
12; CHECK: br %r14
13 %ax = zext i32 %a to i64
14 %bx = zext i32 %b to i64
15 %mulx = mul i64 %ax, %bx
16 %highx = lshr i64 %mulx, 32
17 %high = trunc i64 %highx to i32
18 ret i32 %high
19}
20
21; Check sign-extended multiplication in which only the high part is used.
22define i32 @f2(i32 %a, i32 %b) {
Stephen Lind24ab202013-07-14 06:24:09 +000023; CHECK-LABEL: f2:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000024; CHECK: msgfr
25; CHECK: br %r14
26 %ax = sext i32 %a to i64
27 %bx = sext i32 %b to i64
28 %mulx = mul i64 %ax, %bx
29 %highx = lshr i64 %mulx, 32
30 %high = trunc i64 %highx to i32
31 ret i32 %high
32}
33
34; Check zero-extended multiplication in which the result is split into
35; high and low halves.
36define i32 @f3(i32 %a, i32 %b) {
Stephen Lind24ab202013-07-14 06:24:09 +000037; CHECK-LABEL: f3:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000038; CHECK: msgr
39; CHECK: br %r14
40 %ax = zext i32 %a to i64
41 %bx = zext i32 %b to i64
42 %mulx = mul i64 %ax, %bx
43 %highx = lshr i64 %mulx, 32
44 %high = trunc i64 %highx to i32
45 %low = trunc i64 %mulx to i32
46 %or = or i32 %high, %low
47 ret i32 %or
48}
49
50; Check sign-extended multiplication in which the result is split into
51; high and low halves.
52define i32 @f4(i32 %a, i32 %b) {
Stephen Lind24ab202013-07-14 06:24:09 +000053; CHECK-LABEL: f4:
Ulrich Weigand9e3577f2013-05-06 16:17:29 +000054; CHECK: msgfr
55; CHECK: br %r14
56 %ax = sext i32 %a to i64
57 %bx = sext i32 %b to i64
58 %mulx = mul i64 %ax, %bx
59 %highx = lshr i64 %mulx, 32
60 %high = trunc i64 %highx to i32
61 %low = trunc i64 %mulx to i32
62 %or = or i32 %high, %low
63 ret i32 %or
64}