This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81982] New: [arm] libstdc++ miscompiled, constant propagation is broken on native arm
- From: "nsz at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 25 Aug 2017 13:18:09 +0000
- Subject: [Bug tree-optimization/81982] New: [arm] libstdc++ miscompiled, constant propagation is broken on native arm
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81982
Bug ID: 81982
Summary: [arm] libstdc++ miscompiled, constant propagation is
broken on native arm
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: nsz at gcc dot gnu.org
Target Milestone: ---
Created attachment 42043
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42043&action=edit
preprocessed libstdc++/libsupc++/guard.cc
since
https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=251260
i see gcc miscompiling guard.cc, but only if the gcc is
native arm-*-linux-gnu, a cross compiler compiles it correctly.
the difference between the native and cross compiler
first shows up at ccp1 in -ftree-dump-all, so i
suspect that tree-ssa-ccp.c got miscompiled in the
native gcc, but i'll need to investigate that further,
meanwhile the diff of the ccp1 output is
--- guard.ii.032t.ccp1.good 2017-08-24 18:41:32.875600385 +0100
+++ guard.ii.032t.ccp1.bad 2017-08-24 18:41:23.503495848 +0100
@@ -235,7 +235,21 @@
;; Function __cxxabiv1::__cxa_guard_acquire (__cxa_guard_acquire,
funcdef_no=227, decl_uid=6043, cgraph_uid=225, symbol_order=227)
+Folding predicate 0 != 0 to 0
+Folding predicate 0 != 0 to 0
+Folding predicate 1 != 0 to 1
+Folding predicate 0 != 0 to 0
+Folding predicate 1 != 0 to 1
+Removing basic block 7
+Removing basic block 9
+Removing basic block 18
+Removing basic block 13
Removing basic block 16
+Merging blocks 6 and 8
+Merging blocks 11 and 12
+Removing basic block 14
+Merging blocks 6 and 10
+Merging blocks 11 and 15
__cxxabiv1::__cxa_guard_acquire (__guard * g)
{
int D.13418;
@@ -254,8 +268,6 @@
int _1;
unsigned int pending_bit.3_2;
unsigned int newv.8_6;
- bool _7;
- int _11;
int _12;
bool _21;
bool retval.1_22;
@@ -263,8 +275,6 @@
int _25;
unsigned char _28;
unsigned char _30;
- bool retval.2_34;
- bool retval.7_37;
bool _47;
int _48;
int _50;
@@ -274,13 +284,7 @@
char _55;
int _56;
__complex__ unsigned int _74;
- unsigned int _75;
- unsigned int _76;
- int _77;
__complex__ unsigned int _80;
- unsigned int _81;
- unsigned int _82;
- int _83;
<bb 2> [100.00%] [count: INV]:
_30 = __atomic_load_1 (g_18(D), 2);
@@ -293,7 +297,7 @@
<bb 3> [0.00%] [count: INV]:
// predicted unlikely by early return (on trees) predictor.
- goto <bb 23>; [INV] [count: INV]
+ goto <bb 14>; [INV] [count: INV]
<bb 4> [100.00%] [count: INV]:
_47 = __gthrw___pthread_key_create != 0B;
@@ -304,7 +308,7 @@
if (retval.1_22 != 0)
goto <bb 5>; [INV] [count: INV]
else
- goto <bb 18>; [INV] [count: INV]
+ goto <bb 9>; [INV] [count: INV]
<bb 5> [100.00%] [count: INV]:
__u.__i = 0;
@@ -319,107 +323,50 @@
<bb 6> [0.00%] [count: INV]:
pending_bit.3_2 = (unsigned int) _52;
_74 = ATOMIC_COMPARE_EXCHANGE (g_18(D), 0, pending_bit.3_2, 4, 4, 2);
- _75 = IMAGPART_EXPR <_74>;
- retval.2_34 = (bool) _75;
- _76 = REALPART_EXPR <_74>;
- _77 = VIEW_CONVERT_EXPR<int>(_76);
- if (retval.2_34 != 0)
+ if (_52 == 0)
goto <bb 7>; [INV] [count: INV]
else
goto <bb 8>; [INV] [count: INV]
<bb 7> [0.00%] [count: INV]:
- // predicted unlikely by early return (on trees) predictor.
- goto <bb 17>; [INV] [count: INV]
-
- <bb 8> [0.00%] [count: INV]:
- if (_77 == 1)
- goto <bb 9>; [INV] [count: INV]
- else
- goto <bb 10>; [INV] [count: INV]
-
- <bb 9> [0.00%] [count: INV]:
- // predicted unlikely by early return (on trees) predictor.
- goto <bb 17>; [INV] [count: INV]
-
- <bb 10> [0.00%] [count: INV]:
- if (_52 == _77)
- goto <bb 11>; [INV] [count: INV]
- else
- goto <bb 16>; [INV] [count: INV]
-
- <bb 11> [0.00%] [count: INV]:
- newv_35 = _50 | _77;
- newv.8_6 = (unsigned int) newv_35;
- _80 = ATOMIC_COMPARE_EXCHANGE (g_18(D), _76, newv.8_6, 4, 4, 2);
- _81 = IMAGPART_EXPR <_80>;
- _7 = (bool) _81;
- _82 = REALPART_EXPR <_80>;
- _83 = VIEW_CONVERT_EXPR<int>(_82);
- retval.7_37 = ~_7;
- if (retval.7_37 != 0)
- goto <bb 12>; [INV] [count: INV]
- else
- goto <bb 16>; [INV] [count: INV]
-
- <bb 12> [0.00%] [count: INV]:
- if (_83 == 1)
- goto <bb 13>; [INV] [count: INV]
- else
- goto <bb 14>; [INV] [count: INV]
-
- <bb 13> [0.00%] [count: INV]:
- // predicted unlikely by early return (on trees) predictor.
- goto <bb 17>; [INV] [count: INV]
-
- <bb 14> [0.00%] [count: INV]:
- if (_83 == 0)
- goto <bb 15>; [INV] [count: INV]
- else
- goto <bb 16>; [INV] [count: INV]
-
- <bb 15> [0.00%] [count: INV]:
+ newv.8_6 = (unsigned int) _50;
+ _80 = ATOMIC_COMPARE_EXCHANGE (g_18(D), 0, newv.8_6, 4, 4, 2);
// predicted unlikely by continue predictor.
goto <bb 6>; [INV] [count: INV]
- <bb 16> [0.00%] [count: INV]:
- # expected_84 = PHI <_77(10), newv_35(14), newv_35(11)>
- syscall (240, g_18(D), 0, expected_84, 0);
+ <bb 8> [0.00%] [count: INV]:
+ syscall (240, g_18(D), 0, 0, 0);
goto <bb 6>; [INV] [count: INV]
- <bb 17> [0.00%] [count: INV]:
- # _11 = PHI <1(7), 0(9), 0(13)>
- goto <bb 23>; [INV] [count: INV]
-
- <bb 18> [100.00%] [count: INV]:
+ <bb 9> [100.00%] [count: INV]:
_53 = *g_18(D);
_54 = _53 & 1;
if (_54 != 0)
- goto <bb 22>; [34.00%] [count: INV]
+ goto <bb 13>; [34.00%] [count: INV]
else
- goto <bb 19>; [66.00%] [count: INV]
+ goto <bb 10>; [66.00%] [count: INV]
- <bb 19> [66.00%] [count: INV]:
+ <bb 10> [66.00%] [count: INV]:
_55 = MEM[(char *)g_18(D) + 1B];
if (_55 != 0)
- goto <bb 20>; [0.04%] [count: INV]
+ goto <bb 11>; [0.04%] [count: INV]
else
- goto <bb 21>; [99.96%] [count: INV]
+ goto <bb 12>; [99.96%] [count: INV]
- <bb 20> [0.03%] [count: INV]:
+ <bb 11> [0.03%] [count: INV]:
__cxxabiv1::throw_recursive_init_exception ();
- <bb 21> [65.97%] [count: INV]:
+ <bb 12> [65.97%] [count: INV]:
MEM[(char *)g_18(D) + 1B] = 1;
- <bb 22> [99.97%] [count: INV]:
- # _56 = PHI <0(18), 1(21)>
+ <bb 13> [99.97%] [count: INV]:
+ # _56 = PHI <0(9), 1(12)>
_63 = _56;
_24 = _63;
_25 = _24;
- <bb 23> [0.00%] [count: INV]:
- # _12 = PHI <0(3), _11(17), _25(22)>
+ <bb 14> [0.00%] [count: INV]:
+ # _12 = PHI <0(3), _25(13)>
return _12;
}