Skip to content

Commit 07fa7fc

Browse files
committed
[InstCombine][X86] Add multiply-by-one tests for PMULH/PMULHU/PMULHRS intrinsics
PMULH/PMULHU will simplify, PMULHRS doesn't really and we're better off keeping the intrinsic
1 parent 56f0ecd commit 07fa7fc

File tree

3 files changed

+174
-0
lines changed

3 files changed

+174
-0
lines changed

llvm/test/Transforms/InstCombine/X86/x86-pmulh.ll

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,64 @@ define <32 x i16> @zero_pmulh_512_commute(<32 x i16> %a0) {
105105
ret <32 x i16> %1
106106
}
107107

108+
;
109+
; Multiply by One
110+
;
111+
112+
define <8 x i16> @one_pmulh_128(<8 x i16> %a0) {
113+
; CHECK-LABEL: @one_pmulh_128(
114+
; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.sse2.pmulh.w(<8 x i16> [[A0:%.*]], <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
115+
; CHECK-NEXT: ret <8 x i16> [[TMP1]]
116+
;
117+
%1 = call <8 x i16> @llvm.x86.sse2.pmulh.w(<8 x i16> %a0, <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
118+
ret <8 x i16> %1
119+
}
120+
121+
define <8 x i16> @one_pmulh_128_commute(<8 x i16> %a0) {
122+
; CHECK-LABEL: @one_pmulh_128_commute(
123+
; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.sse2.pmulh.w(<8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <8 x i16> [[A0:%.*]])
124+
; CHECK-NEXT: ret <8 x i16> [[TMP1]]
125+
;
126+
%1 = call <8 x i16> @llvm.x86.sse2.pmulh.w(<8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <8 x i16> %a0)
127+
ret <8 x i16> %1
128+
}
129+
130+
define <16 x i16> @one_pmulh_256(<16 x i16> %a0) {
131+
; CHECK-LABEL: @one_pmulh_256(
132+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.pmulh.w(<16 x i16> [[A0:%.*]], <16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
133+
; CHECK-NEXT: ret <16 x i16> [[TMP1]]
134+
;
135+
%1 = call <16 x i16> @llvm.x86.avx2.pmulh.w(<16 x i16> %a0, <16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
136+
ret <16 x i16> %1
137+
}
138+
139+
define <16 x i16> @one_pmulh_256_commute(<16 x i16> %a0) {
140+
; CHECK-LABEL: @one_pmulh_256_commute(
141+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.pmulh.w(<16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <16 x i16> [[A0:%.*]])
142+
; CHECK-NEXT: ret <16 x i16> [[TMP1]]
143+
;
144+
%1 = call <16 x i16> @llvm.x86.avx2.pmulh.w(<16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <16 x i16> %a0)
145+
ret <16 x i16> %1
146+
}
147+
148+
define <32 x i16> @one_pmulh_512(<32 x i16> %a0) {
149+
; CHECK-LABEL: @one_pmulh_512(
150+
; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i16> @llvm.x86.avx512.pmulh.w.512(<32 x i16> [[A0:%.*]], <32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
151+
; CHECK-NEXT: ret <32 x i16> [[TMP1]]
152+
;
153+
%1 = call <32 x i16> @llvm.x86.avx512.pmulh.w.512(<32 x i16> %a0, <32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
154+
ret <32 x i16> %1
155+
}
156+
157+
define <32 x i16> @one_pmulh_512_commute(<32 x i16> %a0) {
158+
; CHECK-LABEL: @one_pmulh_512_commute(
159+
; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i16> @llvm.x86.avx512.pmulh.w.512(<32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <32 x i16> [[A0:%.*]])
160+
; CHECK-NEXT: ret <32 x i16> [[TMP1]]
161+
;
162+
%1 = call <32 x i16> @llvm.x86.avx512.pmulh.w.512(<32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <32 x i16> %a0)
163+
ret <32 x i16> %1
164+
}
165+
108166
;
109167
; Constant Folding
110168
;

llvm/test/Transforms/InstCombine/X86/x86-pmulhrs.ll

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,64 @@ define <32 x i16> @zero_pmulh_512_commute(<32 x i16> %a0) {
105105
ret <32 x i16> %1
106106
}
107107

108+
;
109+
; Multiply by One
110+
;
111+
112+
define <8 x i16> @one_pmulh_128(<8 x i16> %a0) {
113+
; CHECK-LABEL: @one_pmulh_128(
114+
; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.ssse3.pmul.hr.sw.128(<8 x i16> [[A0:%.*]], <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
115+
; CHECK-NEXT: ret <8 x i16> [[TMP1]]
116+
;
117+
%1 = call <8 x i16> @llvm.x86.ssse3.pmul.hr.sw.128(<8 x i16> %a0, <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
118+
ret <8 x i16> %1
119+
}
120+
121+
define <8 x i16> @one_pmulh_128_commute(<8 x i16> %a0) {
122+
; CHECK-LABEL: @one_pmulh_128_commute(
123+
; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.ssse3.pmul.hr.sw.128(<8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <8 x i16> [[A0:%.*]])
124+
; CHECK-NEXT: ret <8 x i16> [[TMP1]]
125+
;
126+
%1 = call <8 x i16> @llvm.x86.ssse3.pmul.hr.sw.128(<8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <8 x i16> %a0)
127+
ret <8 x i16> %1
128+
}
129+
130+
define <16 x i16> @one_pmulh_256(<16 x i16> %a0) {
131+
; CHECK-LABEL: @one_pmulh_256(
132+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.pmul.hr.sw(<16 x i16> [[A0:%.*]], <16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
133+
; CHECK-NEXT: ret <16 x i16> [[TMP1]]
134+
;
135+
%1 = call <16 x i16> @llvm.x86.avx2.pmul.hr.sw(<16 x i16> %a0, <16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
136+
ret <16 x i16> %1
137+
}
138+
139+
define <16 x i16> @one_pmulh_256_commute(<16 x i16> %a0) {
140+
; CHECK-LABEL: @one_pmulh_256_commute(
141+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.pmul.hr.sw(<16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <16 x i16> [[A0:%.*]])
142+
; CHECK-NEXT: ret <16 x i16> [[TMP1]]
143+
;
144+
%1 = call <16 x i16> @llvm.x86.avx2.pmul.hr.sw(<16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <16 x i16> %a0)
145+
ret <16 x i16> %1
146+
}
147+
148+
define <32 x i16> @one_pmulh_512(<32 x i16> %a0) {
149+
; CHECK-LABEL: @one_pmulh_512(
150+
; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i16> @llvm.x86.avx512.pmul.hr.sw.512(<32 x i16> [[A0:%.*]], <32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
151+
; CHECK-NEXT: ret <32 x i16> [[TMP1]]
152+
;
153+
%1 = call <32 x i16> @llvm.x86.avx512.pmul.hr.sw.512(<32 x i16> %a0, <32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
154+
ret <32 x i16> %1
155+
}
156+
157+
define <32 x i16> @one_pmulh_512_commute(<32 x i16> %a0) {
158+
; CHECK-LABEL: @one_pmulh_512_commute(
159+
; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i16> @llvm.x86.avx512.pmul.hr.sw.512(<32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <32 x i16> [[A0:%.*]])
160+
; CHECK-NEXT: ret <32 x i16> [[TMP1]]
161+
;
162+
%1 = call <32 x i16> @llvm.x86.avx512.pmul.hr.sw.512(<32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <32 x i16> %a0)
163+
ret <32 x i16> %1
164+
}
165+
108166
;
109167
; Constant Folding
110168
;

llvm/test/Transforms/InstCombine/X86/x86-pmulhu.ll

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,64 @@ define <32 x i16> @zero_pmulhu_512_commute(<32 x i16> %a0) {
105105
ret <32 x i16> %1
106106
}
107107

108+
;
109+
; Multiply by One
110+
;
111+
112+
define <8 x i16> @one_pmulhu_128(<8 x i16> %a0) {
113+
; CHECK-LABEL: @one_pmulhu_128(
114+
; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.sse2.pmulhu.w(<8 x i16> [[A0:%.*]], <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
115+
; CHECK-NEXT: ret <8 x i16> [[TMP1]]
116+
;
117+
%1 = call <8 x i16> @llvm.x86.sse2.pmulhu.w(<8 x i16> %a0, <8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
118+
ret <8 x i16> %1
119+
}
120+
121+
define <8 x i16> @one_pmulhu_128_commute(<8 x i16> %a0) {
122+
; CHECK-LABEL: @one_pmulhu_128_commute(
123+
; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i16> @llvm.x86.sse2.pmulhu.w(<8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <8 x i16> [[A0:%.*]])
124+
; CHECK-NEXT: ret <8 x i16> [[TMP1]]
125+
;
126+
%1 = call <8 x i16> @llvm.x86.sse2.pmulhu.w(<8 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <8 x i16> %a0)
127+
ret <8 x i16> %1
128+
}
129+
130+
define <16 x i16> @one_pmulhu_256(<16 x i16> %a0) {
131+
; CHECK-LABEL: @one_pmulhu_256(
132+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.pmulhu.w(<16 x i16> [[A0:%.*]], <16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
133+
; CHECK-NEXT: ret <16 x i16> [[TMP1]]
134+
;
135+
%1 = call <16 x i16> @llvm.x86.avx2.pmulhu.w(<16 x i16> %a0, <16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
136+
ret <16 x i16> %1
137+
}
138+
139+
define <16 x i16> @one_pmulhu_256_commute(<16 x i16> %a0) {
140+
; CHECK-LABEL: @one_pmulhu_256_commute(
141+
; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i16> @llvm.x86.avx2.pmulhu.w(<16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <16 x i16> [[A0:%.*]])
142+
; CHECK-NEXT: ret <16 x i16> [[TMP1]]
143+
;
144+
%1 = call <16 x i16> @llvm.x86.avx2.pmulhu.w(<16 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <16 x i16> %a0)
145+
ret <16 x i16> %1
146+
}
147+
148+
define <32 x i16> @one_pmulhu_512(<32 x i16> %a0) {
149+
; CHECK-LABEL: @one_pmulhu_512(
150+
; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i16> @llvm.x86.avx512.pmulhu.w.512(<32 x i16> [[A0:%.*]], <32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
151+
; CHECK-NEXT: ret <32 x i16> [[TMP1]]
152+
;
153+
%1 = call <32 x i16> @llvm.x86.avx512.pmulhu.w.512(<32 x i16> %a0, <32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>)
154+
ret <32 x i16> %1
155+
}
156+
157+
define <32 x i16> @one_pmulhu_512_commute(<32 x i16> %a0) {
158+
; CHECK-LABEL: @one_pmulhu_512_commute(
159+
; CHECK-NEXT: [[TMP1:%.*]] = call <32 x i16> @llvm.x86.avx512.pmulhu.w.512(<32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <32 x i16> [[A0:%.*]])
160+
; CHECK-NEXT: ret <32 x i16> [[TMP1]]
161+
;
162+
%1 = call <32 x i16> @llvm.x86.avx512.pmulhu.w.512(<32 x i16> <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>, <32 x i16> %a0)
163+
ret <32 x i16> %1
164+
}
165+
108166
;
109167
; Constant Folding
110168
;

0 commit comments

Comments
 (0)