1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
2 ; RUN: -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
5 ; These tests show that for 32-bit and 64-bit scalars, combining a shift to
6 ; a single multiply-high is only valid when the shift amount is the same as
7 ; the width of the narrow type.
9 ; That is, combining a shift to mulh is only valid for 32-bit when the shift
11 ; Likewise, combining a shift to mulh is only valid for 64-bit when the shift
14 define i32 @test_mulhw(i32 %a, i32 %b) {
15 ; CHECK-LABEL: test_mulhw:
19 %1 = sext i32 %a to i64
20 %2 = sext i32 %b to i64
22 %shr = lshr i64 %mul, 33
23 %tr = trunc i64 %shr to i32
27 define i32 @test_mulhu(i32 %a, i32 %b) {
28 ; CHECK-LABEL: test_mulhu:
32 %1 = zext i32 %a to i64
33 %2 = zext i32 %b to i64
35 %shr = lshr i64 %mul, 33
36 %tr = trunc i64 %shr to i32
40 define i64 @test_mulhd(i64 %a, i64 %b) {
41 ; CHECK-LABEL: test_mulhd:
45 %1 = sext i64 %a to i128
46 %2 = sext i64 %b to i128
47 %mul = mul i128 %1, %2
48 %shr = lshr i128 %mul, 63
49 %tr = trunc i128 %shr to i64
53 define i64 @test_mulhdu(i64 %a, i64 %b) {
54 ; CHECK-LABEL: test_mulhdu:
58 %1 = zext i64 %a to i128
59 %2 = zext i64 %b to i128
60 %mul = mul i128 %1, %2
61 %shr = lshr i128 %mul, 63
62 %tr = trunc i128 %shr to i64
66 define signext i32 @test_mulhw_signext(i32 %a, i32 %b) {
67 ; CHECK-LABEL: test_mulhw_signext:
71 %1 = sext i32 %a to i64
72 %2 = sext i32 %b to i64
74 %shr = lshr i64 %mul, 33
75 %tr = trunc i64 %shr to i32
79 define zeroext i32 @test_mulhu_zeroext(i32 %a, i32 %b) {
80 ; CHECK-LABEL: test_mulhu_zeroext:
84 %1 = zext i32 %a to i64
85 %2 = zext i32 %b to i64
87 %shr = lshr i64 %mul, 33
88 %tr = trunc i64 %shr to i32
92 define signext i64 @test_mulhd_signext(i64 %a, i64 %b) {
93 ; CHECK-LABEL: test_mulhd_signext:
97 %1 = sext i64 %a to i128
98 %2 = sext i64 %b to i128
99 %mul = mul i128 %1, %2
100 %shr = lshr i128 %mul, 63
101 %tr = trunc i128 %shr to i64
105 define zeroext i64 @test_mulhdu_zeroext(i64 %a, i64 %b) {
106 ; CHECK-LABEL: test_mulhdu_zeroext:
110 %1 = zext i64 %a to i128
111 %2 = zext i64 %b to i128
112 %mul = mul i128 %1, %2
113 %shr = lshr i128 %mul, 63
114 %tr = trunc i128 %shr to i64