
#10124: Simple case analyses generate too many branches -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: #6135, | Differential Revisions: #9661,#10137 | -------------------------------------+------------------------------------- Comment (by nomeata): Hmm, given the example from comment:10, we currently generate this code: {{{ block_c3S3_info: _c3S3: movq 7(%rbx),%rax cmpq $10,%rax jb _u3Si _u3Sj: cmpq $11,%rax jb _c3Sh _u3Sk: cmpq $32,%rax jne _c3Se _c3Sh: movl $GHC.Types.True_closure+2,%ebx addq $8,%rbp jmp *(%rbp) _c3S7: movl $myIsSpace_rkB_closure,%ebx jmp *-8(%r13) _c3Se: movl $GHC.Types.False_closure+1,%ebx addq $8,%rbp jmp *(%rbp) _u3Si: cmpq $9,%rax jb _c3Se jmp _c3Sh }}} while my code now generates {{{ _c3S3: movq 7(%rbx),%rax cmpq $32,%rax setne %bl movzbl %bl,%ebx cmpq $10,%rax setne %cl movzbl %cl,%ecx andq %rbx,%rcx cmpq $9,%rax setne %al movzbl %al,%eax andq %rcx,%rax testq %rax,%rax jne _c3Se _c3Sh: movl $GHC.Types.True_closure+2,%ebx addq $8,%rbp jmp *(%rbp) _c3S7: movl $myIsSpace_rkB_closure,%ebx jmp *-8(%r13) _c3Se: movl $GHC.Types.False_closure+1,%ebx addq $8,%rbp jmp *(%rbp) .size myIsSpace_rkB_info, .-myIsSpace_rkB_info }}} But not even this simple microbenchmark {{{ main :: IO () main = x `seq` return () where x = length $ filter myIsSpace $ concatMap (replicate 100000000) $ ['\001'..'z'] }}} shows a change in performance. bgamari, is that expected? Is it just that the assembly (generated from {{{ if ((_s3Rr::I64 != 9) & (_s3Rr::I64 != 10) & (_s3Rr::I64 != 32) != 0) goto c3Se; else goto c3Sh; }}} is too bad, or is this not a test case where this will help a lot? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10124#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler