public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/111333] New: Runtime failure for fcmulcph instrinsic
@ 2023-09-08 2:10 crazylht at gmail dot com
2023-09-08 2:12 ` [Bug target/111333] " crazylht at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: crazylht at gmail dot com @ 2023-09-08 2:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111333
Bug ID: 111333
Summary: Runtime failure for fcmulcph instrinsic
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: crazylht at gmail dot com
Target Milestone: ---
cat main.cpp
#include <immintrin.h>
#include <cstdio>
__attribute__((optimize("O0")))
auto func0(_Float16 *a, _Float16 *b, int n, _Float16 *c) {
__m512h rA = _mm512_loadu_ph(a);
for (int i = 0; i < n; i += 32) {
__m512h rB = _mm512_loadu_ph(b + i);
_mm512_storeu_ph(c + i, _mm512_fcmul_pch(rB, rA));
}
}
__attribute__((optimize("O2")))
auto func1(_Float16 *a, _Float16 *b, int n, _Float16 *c) {
__m512h rA = _mm512_loadu_ph(a);
for (int i = 0; i < n; i += 32) {
__m512h rB = _mm512_loadu_ph(b + i);
_mm512_storeu_ph(c + i, _mm512_fcmul_pch(rB, rA));
}
}
int main() {
int n = 32;
_Float16 a[n], b[n], c[n];
for (int i = 1; i <= n; i++) {
a[i - 1] = i & 1 ? -i : i;
b[i - 1] = i;
}
printf("a = %f + %fi \n", (float)a[0], (float)a[1]);
printf("b = %f + %fi \n", (float)b[0], (float)b[1]);
printf("b * conj(a) = %f + %fi \n\n", (float)(a[0]*b[0] + a[1]*b[1]),
(float)(a[0]*b[1] - a[1]*b[0]));
func0(a, b, n, c);
for (int i = 0; i < n / 32 * 2; i++) {
printf("%f ", (float)c[i]);
}
printf("\n");
func1(a, b, n, c);
for (int i = 0; i < n / 32 * 2; i++) {
printf("%f ", (float)c[i]);
}
printf("\n");
return 0;
}
g++ -march=sapphirerapids main.cpp -o test
sde -spr-- ./test
a = -1.000000 + 2.000000i
b = 1.000000 + 2.000000i
b * conj(a) = 3.000000 + -4.000000i
3.000000 -4.000000
3.000000 4.000000
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/111333] Runtime failure for fcmulcph instrinsic
2023-09-08 2:10 [Bug target/111333] New: Runtime failure for fcmulcph instrinsic crazylht at gmail dot com
@ 2023-09-08 2:12 ` crazylht at gmail dot com
2023-09-08 2:14 ` crazylht at gmail dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: crazylht at gmail dot com @ 2023-09-08 2:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111333
--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
fmulcph/fmaddcph is commutative for operands[1] and operands[2], but
fcmulcph/fcmaddcph is not, since it's Complex conjugate operations.
Below change fixes the issue.
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 6d3ae8dea0c..833546c5228 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -6480,6 +6480,14 @@ (define_int_attr complexpairopname
[(UNSPEC_COMPLEX_FMA_PAIR "fmaddc")
(UNSPEC_COMPLEX_FCMA_PAIR "fcmaddc")])
+(define_int_attr int_comm
+ [(UNSPEC_COMPLEX_FMA "%")
+ (UNSPEC_COMPLEX_FMA_PAIR "%")
+ (UNSPEC_COMPLEX_FCMA "")
+ (UNSPEC_COMPLEX_FCMA_PAIR "")
+ (UNSPEC_COMPLEX_FMUL "%")
+ (UNSPEC_COMPLEX_FCMUL "")])
+
(define_int_attr conj_op
[(UNSPEC_COMPLEX_FMA "")
(UNSPEC_COMPLEX_FCMA "_conj")
@@ -6593,7 +6601,7 @@ (define_expand "cmla<conj_op><mode>4"
(define_insn "fma_<complexopname>_<mode><sdc_maskz_name><round_name>"
[(set (match_operand:VHF_AVX512VL 0 "register_operand" "=&v")
(unspec:VHF_AVX512VL
- [(match_operand:VHF_AVX512VL 1 "<round_nimm_predicate>" "%v")
+ [(match_operand:VHF_AVX512VL 1 "<round_nimm_predicate>"
"<int_comm>v")
(match_operand:VHF_AVX512VL 2 "<round_nimm_predicate>"
"<round_constraint>")
(match_operand:VHF_AVX512VL 3 "<round_nimm_predicate>" "0")]
UNSPEC_COMPLEX_F_C_MA))]
@@ -6658,7 +6666,7 @@ (define_insn_and_split
"fma_<complexopname>_<mode>_fma_zero"
(define_insn "fma_<complexpairopname>_<mode>_pair"
[(set (match_operand:VF1_AVX512VL 0 "register_operand" "=&v")
(unspec:VF1_AVX512VL
- [(match_operand:VF1_AVX512VL 1 "vector_operand" "%v")
+ [(match_operand:VF1_AVX512VL 1 "vector_operand" "<int_comm>v")
(match_operand:VF1_AVX512VL 2 "bcst_vector_operand" "vmBr")
(match_operand:VF1_AVX512VL 3 "vector_operand" "0")]
UNSPEC_COMPLEX_F_C_MA_PAIR))]
@@ -6727,7 +6735,7 @@ (define_insn
"<avx512>_<complexopname>_<mode>_mask<round_name>"
[(set (match_operand:VHF_AVX512VL 0 "register_operand" "=&v")
(vec_merge:VHF_AVX512VL
(unspec:VHF_AVX512VL
- [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand" "%v")
+ [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand"
"<int_comm>v")
(match_operand:VHF_AVX512VL 2 "nonimmediate_operand"
"<round_constraint>")
(match_operand:VHF_AVX512VL 3 "register_operand" "0")]
UNSPEC_COMPLEX_F_C_MA)
@@ -6752,7 +6760,7 @@ (define_expand "cmul<conj_op><mode>3"
(define_insn "<avx512>_<complexopname>_<mode><maskc_name><round_name>"
[(set (match_operand:VHF_AVX512VL 0 "register_operand" "=&v")
(unspec:VHF_AVX512VL
- [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand" "%v")
+ [(match_operand:VHF_AVX512VL 1 "nonimmediate_operand"
"<int_comm>v")
(match_operand:VHF_AVX512VL 2 "nonimmediate_operand"
"<round_constraint>")]
UNSPEC_COMPLEX_F_C_MUL))]
"TARGET_AVX512FP16 && <round_mode512bit_condition>"
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/111333] Runtime failure for fcmulcph instrinsic
2023-09-08 2:10 [Bug target/111333] New: Runtime failure for fcmulcph instrinsic crazylht at gmail dot com
2023-09-08 2:12 ` [Bug target/111333] " crazylht at gmail dot com
@ 2023-09-08 2:14 ` crazylht at gmail dot com
2023-09-08 2:17 ` pinskia at gcc dot gnu.org
2023-09-08 2:18 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: crazylht at gmail dot com @ 2023-09-08 2:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111333
--- Comment #2 from Hongtao.liu <crazylht at gmail dot com> ---
The test failed since GCC12 when the pattern is added
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/111333] Runtime failure for fcmulcph instrinsic
2023-09-08 2:10 [Bug target/111333] New: Runtime failure for fcmulcph instrinsic crazylht at gmail dot com
2023-09-08 2:12 ` [Bug target/111333] " crazylht at gmail dot com
2023-09-08 2:14 ` crazylht at gmail dot com
@ 2023-09-08 2:17 ` pinskia at gcc dot gnu.org
2023-09-08 2:18 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-08 2:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111333
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Isn't this a dup of bug 111306 ?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug target/111333] Runtime failure for fcmulcph instrinsic
2023-09-08 2:10 [Bug target/111333] New: Runtime failure for fcmulcph instrinsic crazylht at gmail dot com
` (2 preceding siblings ...)
2023-09-08 2:17 ` pinskia at gcc dot gnu.org
@ 2023-09-08 2:18 ` pinskia at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-08 2:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111333
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes this is an exact dup.
*** This bug has been marked as a duplicate of bug 111306 ***
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-09-08 2:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-08 2:10 [Bug target/111333] New: Runtime failure for fcmulcph instrinsic crazylht at gmail dot com
2023-09-08 2:12 ` [Bug target/111333] " crazylht at gmail dot com
2023-09-08 2:14 ` crazylht at gmail dot com
2023-09-08 2:17 ` pinskia at gcc dot gnu.org
2023-09-08 2:18 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).