Raymond Toy pushed to branch issue-249-replace-lea-in-arith at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/compiler/x86/arith.lisp
    ... ... @@ -222,13 +222,8 @@
    222 222
       (:result-types tagged-num)
    
    223 223
       (:note _N"inline fixnum arithmetic")
    
    224 224
       (:generator 2
    
    225
    -    (cond #+nil
    
    226
    -          ((and (sc-is x any-reg) (sc-is y any-reg) (sc-is r any-reg)
    
    227
    -		(not (location= x r)))
    
    228
    -	   (inst lea r (make-ea :dword :base x :index y :scale 1)))
    
    229
    -	  (t
    
    230
    -	   (move r x)
    
    231
    -	   (inst add r y)))))
    
    225
    +    (move r x)
    
    226
    +    (inst add r y)))
    
    232 227
     
    
    233 228
     (define-vop (fast-+-c/fixnum=>fixnum fast-safe-arith-op)
    
    234 229
       (:translate +)
    
    ... ... @@ -240,12 +235,8 @@
    240 235
       (:result-types tagged-num)
    
    241 236
       (:note _N"inline fixnum arithmetic")
    
    242 237
       (:generator 1
    
    243
    -    (cond #+nil
    
    244
    -          ((and (sc-is x any-reg) (sc-is r any-reg) (not (location= x r)))
    
    245
    -	   (inst lea r (make-ea :dword :base x :disp (fixnumize y))))
    
    246
    -	  (t
    
    247
    -	   (move r x)
    
    248
    -	   (inst add r (fixnumize y))))))
    
    238
    +    (move r x)
    
    239
    +    (inst add r (fixnumize y))))
    
    249 240
     
    
    250 241
     (define-vop (fast-+/signed=>signed fast-safe-arith-op)
    
    251 242
       (:translate +)
    
    ... ... @@ -263,13 +254,8 @@
    263 254
       (:result-types signed-num)
    
    264 255
       (:note _N"inline (signed-byte 32) arithmetic")
    
    265 256
       (:generator 5
    
    266
    -    (cond #+nil
    
    267
    -          ((and (sc-is x signed-reg) (sc-is y signed-reg) (sc-is r signed-reg)
    
    268
    -		(not (location= x r)))
    
    269
    -	   (inst lea r (make-ea :dword :base x :index y :scale 1)))
    
    270
    -	  (t
    
    271
    -	   (move r x)
    
    272
    -	   (inst add r y)))))
    
    257
    +    (move r x)
    
    258
    +    (inst add r y)))
    
    273 259
     
    
    274 260
     (define-vop (fast-+-c/signed=>signed fast-safe-arith-op)
    
    275 261
       (:translate +)
    
    ... ... @@ -281,15 +267,10 @@
    281 267
       (:result-types signed-num)
    
    282 268
       (:note _N"inline (signed-byte 32) arithmetic")
    
    283 269
       (:generator 4
    
    284
    -    (cond #+nil
    
    285
    -          ((and (sc-is x signed-reg) (sc-is r signed-reg)
    
    286
    -		(not (location= x r)))
    
    287
    -	   (inst lea r (make-ea :dword :base x :disp y)))
    
    288
    -	  (t
    
    289
    -	   (move r x)
    
    290
    -	   (if (= y 1)
    
    291
    -	       (inst inc r)
    
    292
    -	     (inst add r y))))))
    
    270
    +    (move r x)
    
    271
    +    (if (= y 1)
    
    272
    +	(inst inc r)
    
    273
    +	(inst add r y))))
    
    293 274
     
    
    294 275
     (define-vop (fast-+/unsigned=>unsigned fast-safe-arith-op)
    
    295 276
       (:translate +)
    
    ... ... @@ -308,13 +289,8 @@
    308 289
       (:result-types unsigned-num)
    
    309 290
       (:note _N"inline (unsigned-byte 32) arithmetic")
    
    310 291
       (:generator 5
    
    311
    -    (cond #+nil
    
    312
    -          ((and (sc-is x unsigned-reg) (sc-is y unsigned-reg)
    
    313
    -		(sc-is r unsigned-reg) (not (location= x r)))
    
    314
    -	   (inst lea r (make-ea :dword :base x :index y :scale 1)))
    
    315
    -	  (t
    
    316
    -	   (move r x)
    
    317
    -	   (inst add r y)))))
    
    292
    +    (move r x)
    
    293
    +    (inst add r y)))
    
    318 294
     
    
    319 295
     (define-vop (fast-+-c/unsigned=>unsigned fast-safe-arith-op)
    
    320 296
       (:translate +)
    
    ... ... @@ -326,17 +302,10 @@
    326 302
       (:result-types unsigned-num)
    
    327 303
       (:note _N"inline (unsigned-byte 32) arithmetic")
    
    328 304
       (:generator 4
    
    329
    -    (cond #+nil
    
    330
    -          ((and (sc-is x unsigned-reg)
    
    331
    -		(sc-is r unsigned-reg)
    
    332
    -		(not (location= x r))
    
    333
    -		(valid-displacement-p y))
    
    334
    -	   (inst lea r (make-ea :dword :base x :disp y)))
    
    335
    -	  (t
    
    336
    -	   (move r x)
    
    337
    -	   (if (= y 1)
    
    338
    -	       (inst inc r)
    
    339
    -	       (inst add r y))))))
    
    305
    +    (move r x)
    
    306
    +    (if (= y 1)
    
    307
    +	(inst inc r)
    
    308
    +	(inst add r y))))
    
    340 309
     
    
    341 310
     
    
    342 311
     ;;;; Special logand cases: (logand signed unsigned) => unsigned
    
    ... ... @@ -647,28 +616,18 @@
    647 616
       (:result-types tagged-num)
    
    648 617
       (:note _N"inline ASH")
    
    649 618
       (:generator 2
    
    650
    -    (cond #+nil
    
    651
    -          ((and (= amount 1) (not (location= number result)))
    
    652
    -	   (inst lea result (make-ea :dword :index number :scale 2)))
    
    653
    -	  #+nil
    
    654
    -          ((and (= amount 2) (not (location= number result)))
    
    655
    -	   (inst lea result (make-ea :dword :index number :scale 4)))
    
    656
    -	  #+nil
    
    657
    -          ((and (= amount 3) (not (location= number result)))
    
    658
    -	   (inst lea result (make-ea :dword :index number :scale 8)))
    
    619
    +    (move result number)
    
    620
    +    (cond ((plusp amount)
    
    621
    +	   ;; We don't have to worry about overflow because of the
    
    622
    +	   ;; result type restriction.
    
    623
    +	   (inst shl result amount))
    
    659 624
     	  (t
    
    660
    -	   (move result number)
    
    661
    -	   (cond ((plusp amount)
    
    662
    -		  ;; We don't have to worry about overflow because of the
    
    663
    -		  ;; result type restriction.
    
    664
    -		  (inst shl result amount))
    
    665
    -		 (t
    
    666
    -		  ;; If the amount is greater than 31, only shift by 31.  We
    
    667
    -		  ;; have to do this because the shift instructions only look
    
    668
    -		  ;; at the low five bits of the result.
    
    669
    -		  (inst sar result (min 31 (- amount)))
    
    670
    -		  ;; Fixnum correction.
    
    671
    -		  (inst and result #xfffffffc)))))))
    
    625
    +	   ;; If the amount is greater than 31, only shift by 31.  We
    
    626
    +	   ;; have to do this because the shift instructions only look
    
    627
    +	   ;; at the low five bits of the result.
    
    628
    +	   (inst sar result (min 31 (- amount)))
    
    629
    +	   ;; Fixnum correction.
    
    630
    +	   (inst and result #xfffffffc)))))
    
    672 631
     
    
    673 632
     (define-vop (fast-ash-left/fixnum=>fixnum)
    
    674 633
       (:translate ash)
    
    ... ... @@ -708,25 +667,15 @@
    708 667
       (:result-types unsigned-num)
    
    709 668
       (:note _N"inline ASH")
    
    710 669
       (:generator 3
    
    711
    -    (cond #+nil
    
    712
    -          ((and (= amount 1) (not (location= number result)))
    
    713
    -	   (inst lea result (make-ea :dword :index number :scale 2)))
    
    714
    -	  #+nil
    
    715
    -          ((and (= amount 2) (not (location= number result)))
    
    716
    -	   (inst lea result (make-ea :dword :index number :scale 4)))
    
    717
    -	  #+nil
    
    718
    -          ((and (= amount 3) (not (location= number result)))
    
    719
    -	   (inst lea result (make-ea :dword :index number :scale 8)))
    
    670
    +    (move result number)
    
    671
    +    (cond ((plusp amount)
    
    672
    +	   ;; We don't have to worry about overflow because of the
    
    673
    +	   ;; result type restriction.
    
    674
    +	   (inst shl result amount))
    
    675
    +	  ((< amount -31)
    
    676
    +	   (inst mov result 0))
    
    720 677
     	  (t
    
    721
    -	   (move result number)
    
    722
    -	   (cond ((plusp amount)
    
    723
    -		  ;; We don't have to worry about overflow because of the
    
    724
    -		  ;; result type restriction.
    
    725
    -		  (inst shl result amount))
    
    726
    -		 ((< amount -31)
    
    727
    -		  (inst mov result 0))
    
    728
    -		 (t
    
    729
    -		  (inst shr result (- amount))))))))
    
    678
    +	   (inst shr result (- amount))))))
    
    730 679
     
    
    731 680
     (define-vop (fast-ash-c/signed=>signed)
    
    732 681
       (:translate ash)
    
    ... ... @@ -744,26 +693,16 @@
    744 693
       (:result-types signed-num)
    
    745 694
       (:note _N"inline ASH")
    
    746 695
       (:generator 3
    
    747
    -    (cond #+nil
    
    748
    -          ((and (= amount 1) (not (location= number result)))
    
    749
    -	   (inst lea result (make-ea :dword :index number :scale 2)))
    
    750
    -	  #+nil
    
    751
    -          ((and (= amount 2) (not (location= number result)))
    
    752
    -	   (inst lea result (make-ea :dword :index number :scale 4)))
    
    753
    -	  #+nil
    
    754
    -          ((and (= amount 3) (not (location= number result)))
    
    755
    -	   (inst lea result (make-ea :dword :index number :scale 8)))
    
    696
    +    (move result number)
    
    697
    +    (cond ((plusp amount)
    
    698
    +	   ;; We don't have to worry about overflow because of the
    
    699
    +	   ;; result type restriction.
    
    700
    +	   (inst shl result amount))
    
    756 701
     	  (t
    
    757
    -	   (move result number)
    
    758
    -	   (cond ((plusp amount)
    
    759
    -		  ;; We don't have to worry about overflow because of the
    
    760
    -		  ;; result type restriction.
    
    761
    -		  (inst shl result amount))
    
    762
    -		 (t
    
    763
    -		  ;; If the amount is greater than 31, only shift by 31.  We
    
    764
    -		  ;; have to do this because the shift instructions only look
    
    765
    -		  ;; at the low five bits of the result.
    
    766
    -		  (inst sar result (min 31 (- amount)))))))))
    
    702
    +	   ;; If the amount is greater than 31, only shift by 31.  We
    
    703
    +	   ;; have to do this because the shift instructions only look
    
    704
    +	   ;; at the low five bits of the result.
    
    705
    +	   (inst sar result (min 31 (- amount)))))))
    
    767 706
     
    
    768 707
     (define-vop (fast-ash-c/fixnum=>signed)
    
    769 708
       (:translate ash)
    
    ... ... @@ -782,26 +721,16 @@
    782 721
       (:note "inline ASH")
    
    783 722
       (:generator 1
    
    784 723
         (let ((shift (- amount vm:fixnum-tag-bits)))
    
    785
    -      (cond #+nil
    
    786
    -            ((and (= shift 1) (not (location= number result)))
    
    787
    -	     (inst lea result (make-ea :dword :index number :scale 2)))
    
    788
    -	    #+nil
    
    789
    -            ((and (= shift 2) (not (location= number result)))
    
    790
    -	     (inst lea result (make-ea :dword :index number :scale 4)))
    
    791
    -	    #+nil
    
    792
    -            ((and (= shift 3) (not (location= number result)))
    
    793
    -	     (inst lea result (make-ea :dword :index number :scale 8)))
    
    724
    +      (move result number)
    
    725
    +      (cond ((plusp shift)
    
    726
    +	     ;; We don't have to worry about overflow because of the
    
    727
    +	     ;; result type restriction.
    
    728
    +	     (inst shl result shift))
    
    794 729
     	    (t
    
    795
    -	     (move result number)
    
    796
    -	     (cond ((plusp shift)
    
    797
    -		    ;; We don't have to worry about overflow because of the
    
    798
    -		    ;; result type restriction.
    
    799
    -		    (inst shl result shift))
    
    800
    -		   (t
    
    801
    -		    ;; If the shift is greater than 31, only shift by 31.  We
    
    802
    -		    ;; have to do this because the shift instructions only look
    
    803
    -		    ;; at the low five bits of the result.
    
    804
    -		    (inst sar result (min 31 (- shift))))))))))
    
    730
    +	     ;; If the shift is greater than 31, only shift by 31.  We
    
    731
    +	     ;; have to do this because the shift instructions only look
    
    732
    +	     ;; at the low five bits of the result.
    
    733
    +	     (inst sar result (min 31 (- shift))))))))
    
    805 734
     
    
    806 735
     (define-vop (fast-ash-left/unsigned=>unsigned)
    
    807 736
       (:translate ash)