This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/53265] Warn when undefined behavior implies smaller iteration count
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 12 Mar 2013 12:35:59 +0000
- Subject: [Bug tree-optimization/53265] Warn when undefined behavior implies smaller iteration count
- Auto-submitted: auto-generated
- References: <bug-53265-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53265
--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-03-12 12:35:59 UTC ---
There is also a problem in unwind-dw2.c, but that looks like something we
should probably fix:
../../../libgcc/unwind-dw2.c: In function âexecute_cfa_programâ:
../../../libgcc/unwind-dw2.c:1133:30: warning: iteration 2ul invokes undefined
behavior [-Waggressive-loop-optimizations]
fs->regs.reg[reg].how = REG_SAVED_OFFSET;
^
../../../libgcc/unwind-dw2.c:1131:4: note: containing loop
for (reg = 16; reg < 32; ++reg)
^
case DW_CFA_GNU_window_save:
/* ??? Hardcoded for SPARC register window configuration. */
for (reg = 16; reg < 32; ++reg)
{
fs->regs.reg[reg].how = REG_SAVED_OFFSET;
fs->regs.reg[reg].loc.offset = (reg - 16) * sizeof (void *);
}
break;
but DWARF_FRAME_REGISTERS is 17 on x86_64/i386, so reg[17] is still ok, but
reg[18] is undefined behavior. Of course it doesn't matter much, because
DW_CFA_GNU_window_save isn't used on non-SPARC, but perhaps we could use
for (reg = 16; reg < MIN (32, DWARF_FRAME_REGISTERS + 1); ++reg)
or similar (I think it wouldn't generate worst code on SPARC, because it would
be still constant folded to 32 there, and to 18 on ix86_64 etc.