Should dead stores which could trap be deleted?

John Wehle john@feith.com
Fri Aug 6 15:41:00 GMT 1999


Consider:

long
subr(long a, long b)
  {
  long c;

  c = a / b;

  return 0;
  }

currently gcc produces;

	pushl %ebp
	movl %esp,%ebp
	xorl %eax,%eax
	leave
	ret

when compiled -O2 on x86 due to dead_trivially_dead_insns.  Consider
the situation where b equals 0 which on the x86 normally causes a
divide by zero exception.  What are the guidelines regarding instructions
which could trap / to what extent is it valid for optimizations to modify
the behaviour of a program with respect to traps?

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



More information about the Gcc mailing list