[Bug tree-optimization/95739] New: [11 Regression] Unordered comparison and VEC_COND_EXPR
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jun 18 10:11:57 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95739
Bug ID: 95739
Summary: [11 Regression] Unordered comparison and VEC_COND_EXPR
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: rguenth at gcc dot gnu.org
Target Milestone: ---
The following is a fallout of
r11-1445-g502d63b6d6141597bb18fd23c87736a1b384cf8f but it seems to me a latent
issue:
$ cat pr50310.c
double s1[4], s2[4], s3[64];
int
main ()
{
s1[0] = __builtin_nan ("");
s1[1] = 6.0;
s1[2] = 6.0;
s1[3] = 6.0;
s2[0] = 5.0;
s2[1] = 5.0;
s2[2] = 5.0;
s2[3] = 5.0;
asm volatile ("" : : : "memory");
for (int i = 0; i < 4; i++)
s3[i] = __builtin_isgreater (s1[i], s2[i]) ? -1.0 : 0.0;
if (s3[1] != -1.0)
__builtin_abort ();
return 0;
}
$ gcc pr50310.c -O3 -ffloat-store && ./a.out
Aborted (core dumped)
The thing is that we newly generate:
--- good 2020-06-18 12:08:56.901799621 +0200
+++ bad 2020-06-18 12:08:54.137825794 +0200
@@ -1,39 +1,43 @@
-;; Function main (main, funcdef_no=0, decl_uid=1937, cgraph_uid=1,
symbol_order=3) (executed once)
+;; Function main (main, funcdef_no=0, decl_uid=1933, cgraph_uid=1,
symbol_order=3) (executed once)
main ()
{
vector(2) double vect_iftmp.11;
vector(2) double vect__2.10;
vector(2) double vect__1.7;
+ vector(2) <signed-boolean:64> _4;
double _14;
+ vector(2) <signed-boolean:64> _43;
<bb 2> [local count: 214748371]:
MEM <vector(2) double> [(double *)&s1] = { Nan, 6.0e+0 };
MEM <vector(2) double> [(double *)&s1 + 16B] = { 6.0e+0, 6.0e+0 };
MEM <vector(2) double> [(double *)&s2] = { 5.0e+0, 5.0e+0 };
MEM <vector(2) double> [(double *)&s2 + 16B] = { 5.0e+0, 5.0e+0 };
__asm__ __volatile__("" : : : "memory");
vect__1.7_5 = MEM <vector(2) double> [(double *)&s1];
vect__2.10_19 = MEM <vector(2) double> [(double *)&s2];
- vect_iftmp.11_4 = VEC_COND_EXPR <vect__1.7_5 u<= vect__2.10_19, { 0.0, 0.0
}, { -1.0e+0, -1.0e+0 }>;
- MEM <vector(2) double> [(double *)&s3] = vect_iftmp.11_4;
+ _4 = vect__1.7_5 u<= vect__2.10_19;
+ vect_iftmp.11_33 = .VCOND (vect__1.7_5, vect__2.10_19, { 0.0, 0.0 }, {
-1.0e+0, -1.0e+0 }, 117);
+ MEM <vector(2) double> [(double *)&s3] = vect_iftmp.11_33;
vect__1.7_37 = MEM <vector(2) double> [(double *)&s1 + 16B];
vect__2.10_40 = MEM <vector(2) double> [(double *)&s2 + 16B];
- vect_iftmp.11_43 = VEC_COND_EXPR <vect__1.7_37 u<= vect__2.10_40, { 0.0, 0.0
}, { -1.0e+0, -1.0e+0 }>;
- MEM <vector(2) double> [(double *)&s3 + 16B] = vect_iftmp.11_43;
- _14 = BIT_FIELD_REF <vect_iftmp.11_4, 64, 64>;
+ _43 = vect__1.7_37 u<= vect__2.10_40;
+ vect_iftmp.11_44 = .VCOND (vect__1.7_37, vect__2.10_40, { 0.0, 0.0 }, {
-1.0e+0, -1.0e+0 }, 117);
+ MEM <vector(2) double> [(double *)&s3 + 16B] = vect_iftmp.11_44;
+ _14 = BIT_FIELD_REF <vect_iftmp.11_33, 64, 64>;
if (_14 != -1.0e+0)
goto <bb 3>; [0.00%]
else
goto <bb 4>; [100.00%]
<bb 3> [count: 0]:
__builtin_abort ();
<bb 4> [local count: 214748368]:
return 0;
}
Looking at the assembly the comparison is somehow gone:
diff -u good.s bad.s
--- good.s 2020-06-18 12:09:52.385274181 +0200
+++ bad.s 2020-06-18 12:09:54.013258763 +0200
@@ -19,31 +19,14 @@
movapd .LC2(%rip), %xmm0
movaps %xmm0, s2(%rip)
movaps %xmm0, s2+16(%rip)
- movapd s2(%rip), %xmm3
- movapd s1(%rip), %xmm2
- movapd .LC3(%rip), %xmm1
- movapd s2+16(%rip), %xmm6
- movaps %xmm3, 48(%rsp)
- movapd 48(%rsp), %xmm0
- movapd s1+16(%rip), %xmm5
- movaps %xmm2, 32(%rsp)
- cmpnltpd 32(%rsp), %xmm0
- movaps %xmm6, 80(%rsp)
- movaps %xmm5, 64(%rsp)
- andnpd %xmm1, %xmm0
- movaps %xmm0, 16(%rsp)
- movapd 80(%rsp), %xmm0
- movapd 16(%rsp), %xmm4
- cmpnltpd 64(%rsp), %xmm0
- movaps %xmm4, s3(%rip)
- andnpd %xmm1, %xmm0
- movaps %xmm0, 96(%rsp)
- movsd 24(%rsp), %xmm0
- movapd 96(%rsp), %xmm7
+ movsd 56(%rsp), %xmm0
+ movapd 48(%rsp), %xmm1
+ movapd 96(%rsp), %xmm2
movsd %xmm0, 8(%rsp)
movsd .LC4(%rip), %xmm0
ucomisd 8(%rsp), %xmm0
- movaps %xmm7, s3+16(%rip)
+ movaps %xmm1, s3(%rip)
+ movaps %xmm2, s3+16(%rip)
jp .L4
comisd 8(%rsp), %xmm0
jne .L4
@@ -107,16 +90,10 @@
.long 1075052544
.long 0
.long 1075052544
- .align 16
-.LC3:
- .long 0
- .long -1074790400
- .long 0
- .long -1074790400
.section .rodata.cst8,"aM",@progbits,8
.align 8
.LC4:
.long 0
.long -1074790400
- .ident "GCC: (SUSE Linux) 10.1.1 20200507 [revision
dd38686d9c810cecbaa80bb82ed91caaa58ad635]"
+ .ident "GCC: (GNU) 11.0.0 20200618 (experimental)"
.section .note.GNU-stack,"",@progbits
More information about the Gcc-bugs
mailing list