This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/14279] New: delete_null_pointer_checks removes live insn
- From: "amodra at bigpond dot net dot au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Feb 2004 22:25:33 -0000
- Subject: [Bug optimization/14279] New: delete_null_pointer_checks removes live insn
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
This testcase, compiled with -O2 -S, results in assembly that tests CR4 but
nowhere sets CR4. Note that I'm reporting the bug against 3.4, but 3.4 needs to
have delete_null_pointer_checks enabled.. See
http://gcc.gnu.org/ml/gcc-patches/2004-02/msg02199.html
void assi (void);
struct C
{
C *pMemPool;
bool isEmpty();
void decrementNumBlocks (C *const pCSG)
{
if (this == 0)
assi ();
if (pCSG)
assi ();
if (pCSG)
assi ();
}
};
void sqlofmblkEx (C *pMemSeg)
{
C *pMemPool = __null;
pMemPool = pMemSeg->pMemPool;
pMemPool->decrementNumBlocks (pMemSeg);
pMemSeg->isEmpty ();
}
The reason is that after cse but before delete_null_pointer_checks, we have rtl
like the following:
(insn 40 75 41 2 0x401ae7c0 (set (reg:CC 123)
(compare:CC (reg/v/f:DI 118 [ pMemSeg ])
(const_int 0 [0x0]))) 376 {*cmpdi_internal1} (nil)
(nil))
(jump_insn 41 40 76 2 0x401ae7c0 (set (pc)
(if_then_else (eq (reg:CC 123)
(const_int 0 [0x0]))
(label_ref 48)
(pc))) 434 {*rs6000.md:13489} (nil)
(nil))
(note 76 41 47 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
(call_insn 47 76 48 3 0x401ae7c0 (parallel [
(call (mem:SI (symbol_ref:DI ("_Z4assiv")) [0 S4 A8])
(const_int 64 [0x40]))
(use (const_int 0 [0x0]))
(clobber (scratch:SI))
]) -1 (nil)
(nil)
(nil))
(code_label 48 47 77 4 3 "" [1 uses])
(note 77 48 53 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(jump_insn 53 77 78 4 0x401ae7c0 (set (pc)
(if_then_else (eq (reg:CC 123)
(const_int 0 [0x0]))
(label_ref 62)
(pc))) 434 {*rs6000.md:13489} (nil)
(nil))
Note how both jumps use reg:CC 123. delete_null_pointer_checks incorrectly
deletes insn 40 when finding that insn 41 is redundant, and is not clever enough
to also delete insn 53.
--
Summary: delete_null_pointer_checks removes live insn
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P2
Component: optimization
AssignedTo: amodra at bigpond dot net dot au
ReportedBy: amodra at bigpond dot net dot au
CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: powerpc64-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14279