From: Alexey D. <ade...@co...> - 2004-08-16 18:32:09
|
Hello, Juho Snellman <js...@ik...> writes: > (defun foo (x) > (declare (optimize (speed 3) (safety 0)) (type (unsigned-byte 32) x)) > ;; Swap the arguments to LOGAND around > (logand (ash (ash x 12) 0) #xffff)) ;; Can't inline ASH ... > Does anyone have ideas on what's going on? By the time of the last call of CUT-TO-WIDTH, the component looks like this: IR1 block 6 start c6 6> bind CLAMBDA FOO successors c7 IR1 block 5 start c7 7> entry NIL 8> 9: LOGAND {GLOBAL-FUNCTION} 10> 11: CLAMBDA "LAMBDA-inlined ASH" 12> 13: X 14> 15: '12 16> 17: '0 18> local combination v11 v13 v15 v17 successors c4 IR1 block NIL start c4 4> bind CLAMBDA "LAMBDA-inlined ASH" :KIND :LET 19> 20: ASH {GLOBAL-FUNCTION} 21> 2: VALUE 22> 23: + {GLOBAL-FUNCTION} 24> 25: AMOUNT1 26> 27: AMOUNT2 28> 29: cast v25 -[#<NAMED-TYPE *> -> #<NUMERIC-TYPE NUMBER>] 30> 31: cast v27 -[#<NAMED-TYPE *> -> #<NUMERIC-TYPE NUMBER>] 32> 3: known combination v23 v29 v31 33> 34: cast v2 -[#<NAMED-TYPE *> -> #<NUMERIC-TYPE INTEGER>] 35> 36: cast v3 -[#<NAMED-TYPE *> -> #<NUMERIC-TYPE INTEGER>] 37> 1: known combination v20 v34 v36 38> 5: '65535 39> 40: known combination v9 v1 v5 successors c41 IR1 block 4 start c41 41> return v40 CLAMBDA FOO successors c42 IR1 block 3 start c43 43> bind CLAMBDA "XEP for SB-C::FOO" :KIND :EXTERNAL 44> 45: CLAMBDA FOO 46> 47: #:G1 48> 49: cast v47 +[#<NAMED-TYPE *> -> #<NUMERIC-TYPE (UNSIGNED-BYTE 32)>] 50> 51: local combination v45 v49 successors c52 IR1 block 2 start c52 52> return v51 CLAMBDA "XEP for SB-C::FOO" successors c42 with the derived type of V1 being (VALUES (MOD 17592186040321) &OPTIONAL) and of V36 being (VALUES INTEGER &OPTIONAL). So cutting cannot be performed. Replacing AMOUNT1 and AMOUNT2 with their values and constant folding gives no new type information for V1, so Python sees no need for reoptimization of '39>'. The problem is that Python reoptimization mechanism is local: it does not recognize patterns, touching several nodes. (Someone doing next commit to the main branch is welcome to put the test case to OPTIMIZATIONS.) -- Regards, Alexey Dejneka "Alas, the spheres of truth are less transparent than those of illusion." -- L.E.J. Brouwer |