Debugging optimized programs presents special problems. Optimization may change the sequence of operations, add or remove code, and do similar things that make it difficult to associate the generated code with the original source statements.
First debug your program, then recompile it with any optimization options, and test the optimized program before placing the program into production. If the optimized code does not produce the expected results, isolate the specific optimization problems in another debugging session.