http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51244
--- Comment #60 from Oleg Endo <olegendo at gcc dot gnu.org> --- (In reply to Laurent Aflonsi from comment #59) > I have a functional regression due to this improvement when we are compiling > the enclosed example in -O2. > $ sh-superh-elf-gcc -O2 pr51244-20-main.c pr51244-20.c > $ sh-superh-elf-run a.out > FAIL > > Thus, the code is transformed from : > _get_request: > mov.l @(12,r4),r1 > tst r1,r1 > bt .L2 > mov.l @(4,r4),r2 > tst r2,r2 > mov #-1,r2 > negc r2,r2 > .L3: > tst r2,r2 > bt/s .L11 > mov #-100,r0 > mov #1,r2 > [...] > > to : > _get_request: > mov.l @(12,r4),r1 > tst r1,r1 > bt .L2 > mov.l @(4,r4),r2 > tst r2,r2 > mov #-1,r2 > negc r2,r2 > .L3: > bf/s .L11 > mov #-100,r0 > mov #1,r2 > [...] > > With the inputs encoded in the main function, we are supposed to follow the > simpliest flow (no jump), but when this optimization is enabled, we are > jumping to L11 to to the bt -> bf transfrmation. The idea was that sequences such as tst r2,r2 mov #-1,r2 negc r2,r2 tst r2,r2 bt ... should be folded to tst r2,r2 bt ... ... if r2 is dead afterwards (which it seems to be). I guess I missed to handle some cases where the tested register is in a loop or can be reached by some other basic block. I'll check out the details.