! { dg-options "-O2 -funroll-loops" } function foo (b) character (len=1) :: b(4) logical :: foo foo = any (b .ne. (/"1","2","3","4"/)) end
results in horrible code: movzbl .LC0(%rip), %edx movl $1, %eax cmpb %dl, (%rdi) jne .L2 movzbl .LC1(%rip), %ecx cmpb %cl, 1(%rdi) jne .L2 movzbl .LC2(%rip), %esi cmpb %sil, 2(%rdi) jne .L2 movzbl .LC3(%rip), %r8d cmpb %r8b, 3(%rdi) setne %al movzbl %al, %eax .L2: rep ret because nothing optimizes the constant array reads after cunroll. If I schedule another pass_ccp right after pass_complete_unroll, much better code is generated: cmpb $49, (%rdi) movl $1, %eax jne .L2 cmpb $50, 1(%rdi) jne .L2 cmpb $51, 2(%rdi) jne .L2 xorl %eax, %eax cmpb $52, 3(%rdi) setne %al .L2: rep ret -- Summary: ccp or similar passes aren't run after cunroll Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jakub at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44669