Merging r260427:
[oota-llvm.git] / test / CodeGen / SystemZ / int-mul-07.ll
1 ; 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.
9 define i32 @f1(i32 %a, i32 %b) {
10 ; CHECK-LABEL: f1:
11 ; 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.
22 define i32 @f2(i32 %a, i32 %b) {
23 ; CHECK-LABEL: f2:
24 ; 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.
36 define i32 @f3(i32 %a, i32 %b) {
37 ; CHECK-LABEL: f3:
38 ; 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.
52 define i32 @f4(i32 %a, i32 %b) {
53 ; CHECK-LABEL: f4:
54 ; 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 }