I have a case where I think useless stores are being generated, but I want to be sure before I file a bug. This is with gcc 4.4.3 on Ubuntu 10.04, x86-64.
I have been experimenting with returning structs from functions instead of passing pointers to "out" parameters. This seems like it should be more optimizer-friendly because you can avoid taking addresses of local variables, which prevents them from possibly being aliased. However in this test case, gcc is generating four stores that appear to be completely useless: #include <stdint.h> struct twoints { uint64_t a, b; } foo(); void bar(uint64_t a, uint64_t b); void func() { struct twoints s = foo(); bar(s.a, s.b); } $ gcc -Wall -c -o testbad.o -msse2 -O3 -fomit-frame-pointer testbad.c- $ objdump -d -r -M intel testbad.o testbad.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <func>: 0: 48 83 ec 28 sub rsp,0x28 4: 31 c0 xor eax,eax 6: e8 00 00 00 00 call b <func+0xb> 7: R_X86_64_PC32 foo-0x4 b: 48 89 04 24 mov QWORD PTR [rsp],rax f: 48 89 54 24 08 mov QWORD PTR [rsp+0x8],rdx 14: 48 89 d6 mov rsi,rdx 17: 48 89 44 24 10 mov QWORD PTR [rsp+0x10],rax 1c: 48 89 54 24 18 mov QWORD PTR [rsp+0x18],rdx 21: 48 89 c7 mov rdi,rax 24: 48 83 c4 28 add rsp,0x28 28: e9 00 00 00 00 jmp 2d <func+0x2d> 29: R_X86_64_PC32 bar-0x4 Why is it storing rax and rdx to the stack twice? These stores are never used AFAICS. Josh