Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

1 changed file:

Changes:

  • compiler/GHC/CmmToAsm/RV64/CodeGen.hs
    ... ... @@ -874,46 +874,18 @@ getRegister' config plat expr =
    874 874
               )
    
    875 875
     
    
    876 876
         -- 2. Shifts. x << n, x >> n.
    
    877
    -    CmmMachOp (MO_Shl w) [x, CmmLit (CmmInt n _)]
    
    878
    -      | w == W32,
    
    879
    -        0 <= n,
    
    880
    -        n < 32 -> do
    
    881
    -          (reg_x, _format_x, code_x) <- getSomeReg x
    
    882
    -          return
    
    883
    -            $ Any
    
    884
    -              (intFormat w)
    
    885
    -              ( \dst ->
    
    886
    -                  code_x
    
    887
    -                    `snocOL` annExpr expr (SLL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))
    
    888
    -                    `appOL` truncateReg w w dst
    
    889
    -              )
    
    890
    -    CmmMachOp (MO_Shl w) [x, CmmLit (CmmInt n _)]
    
    891
    -      | w == W64,
    
    892
    -        0 <= n,
    
    893
    -        n < 64 -> do
    
    894
    -          (reg_x, _format_x, code_x) <- getSomeReg x
    
    895
    -          return
    
    896
    -            $ Any
    
    897
    -              (intFormat w)
    
    898
    -              ( \dst ->
    
    899
    -                  code_x
    
    900
    -                    `snocOL` annExpr expr (SLL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))
    
    901
    -                    `appOL` truncateReg w w dst
    
    902
    -              )
    
    903
    -    CmmMachOp (MO_S_Shr w) [x, CmmLit (CmmInt n _)] | fitsIn12bitImm n -> do
    
    904
    -      (reg_x, format_x, code_x) <- getSomeReg x
    
    905
    -      (reg_x', code_x') <- signExtendReg (formatToWidth format_x) w reg_x
    
    877
    +    CmmMachOp (MO_Shl w) [x, CmmLit (CmmInt n _)] | fitsIn12bitImm n -> do
    
    878
    +      (reg_x, _format_x, code_x) <- getSomeReg x
    
    906 879
           return
    
    907 880
             $ Any
    
    908 881
               (intFormat w)
    
    909 882
               ( \dst ->
    
    910 883
                   code_x
    
    911
    -                `appOL` code_x'
    
    912
    -                `snocOL` annExpr expr (SRA (OpReg w dst) (OpReg w reg_x') (OpImm (ImmInteger n)))
    
    884
    +                `snocOL` annExpr expr (SLL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))
    
    885
    +                `appOL` truncateReg w w dst
    
    913 886
               )
    
    914
    -    CmmMachOp (MO_S_Shr w) [x, y] -> do
    
    887
    +    CmmMachOp (MO_S_Shr w) [x, CmmLit (CmmInt n _)] | fitsIn12bitImm n -> do
    
    915 888
           (reg_x, format_x, code_x) <- getSomeReg x
    
    916
    -      (reg_y, _format_y, code_y) <- getSomeReg y
    
    917 889
           (reg_x', code_x') <- signExtendReg (formatToWidth format_x) w reg_x
    
    918 890
           return
    
    919 891
             $ Any
    
    ... ... @@ -921,72 +893,20 @@ getRegister' config plat expr =
    921 893
               ( \dst ->
    
    922 894
                   code_x
    
    923 895
                     `appOL` code_x'
    
    924
    -                `appOL` code_y
    
    925
    -                `snocOL` annExpr expr (SRA (OpReg w dst) (OpReg w reg_x') (OpReg w reg_y))
    
    896
    +                `snocOL` annExpr expr (SRA (OpReg w dst) (OpReg w reg_x') (OpImm (ImmInteger n)))
    
    897
    +                `appOL` truncateReg w w dst
    
    926 898
               )
    
    927
    -    CmmMachOp (MO_U_Shr w) [x, CmmLit (CmmInt n _)]
    
    928
    -      | w == W8,
    
    929
    -        0 <= n,
    
    930
    -        n < 8 -> do
    
    931
    -          (reg_x, format_x, code_x) <- getSomeReg x
    
    932
    -          return
    
    933
    -            $ Any
    
    934
    -              (intFormat w)
    
    935
    -              ( \dst ->
    
    936
    -                  code_x
    
    937
    -                    `appOL` truncateReg (formatToWidth format_x) w reg_x
    
    938
    -                    `snocOL` annExpr expr (SRL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))
    
    939
    -              )
    
    940
    -    CmmMachOp (MO_U_Shr w) [x, CmmLit (CmmInt n _)]
    
    941
    -      | w == W16,
    
    942
    -        0 <= n,
    
    943
    -        n < 16 -> do
    
    944
    -          (reg_x, format_x, code_x) <- getSomeReg x
    
    945
    -          return
    
    946
    -            $ Any
    
    947
    -              (intFormat w)
    
    948
    -              ( \dst ->
    
    949
    -                  code_x
    
    950
    -                    `appOL` truncateReg (formatToWidth format_x) w reg_x
    
    951
    -                    `snocOL` annExpr expr (SRL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))
    
    952
    -              )
    
    953
    -    CmmMachOp (MO_U_Shr w) [x, y] | w == W8 || w == W16 -> do
    
    899
    +    CmmMachOp (MO_U_Shr w) [x, CmmLit (CmmInt n _)] | fitsIn12bitImm n -> do
    
    954 900
           (reg_x, format_x, code_x) <- getSomeReg x
    
    955
    -      (reg_y, _format_y, code_y) <- getSomeReg y
    
    956 901
           return
    
    957 902
             $ Any
    
    958 903
               (intFormat w)
    
    959 904
               ( \dst ->
    
    960 905
                   code_x
    
    961
    -                `appOL` code_y
    
    962 906
                     `appOL` truncateReg (formatToWidth format_x) w reg_x
    
    963
    -                `snocOL` annExpr expr (SRL (OpReg w dst) (OpReg w reg_x) (OpReg w reg_y))
    
    907
    +                `snocOL` annExpr expr (SRL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))
    
    908
    +                `appOL` truncateReg w w dst
    
    964 909
               )
    
    965
    -    CmmMachOp (MO_U_Shr w) [x, CmmLit (CmmInt n _)]
    
    966
    -      | w == W32,
    
    967
    -        0 <= n,
    
    968
    -        n < 32 -> do
    
    969
    -          (reg_x, _format_x, code_x) <- getSomeReg x
    
    970
    -          return
    
    971
    -            $ Any
    
    972
    -              (intFormat w)
    
    973
    -              ( \dst ->
    
    974
    -                  code_x
    
    975
    -                    `snocOL` annExpr expr (SRL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))
    
    976
    -              )
    
    977
    -    CmmMachOp (MO_U_Shr w) [x, CmmLit (CmmInt n _)]
    
    978
    -      | w == W64,
    
    979
    -        0 <= n,
    
    980
    -        n < 64 -> do
    
    981
    -          (reg_x, _format_x, code_x) <- getSomeReg x
    
    982
    -          return
    
    983
    -            $ Any
    
    984
    -              (intFormat w)
    
    985
    -              ( \dst ->
    
    986
    -                  code_x
    
    987
    -                    `snocOL` annExpr expr (SRL (OpReg w dst) (OpReg w reg_x) (OpImm (ImmInteger n)))
    
    988
    -              )
    
    989
    -
    
    990 910
         -- 3. Logic &&, ||
    
    991 911
         CmmMachOp (MO_And w) [CmmReg reg, CmmLit (CmmInt n _)]
    
    992 912
           | fitsIn12bitImm n ->