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

Commits:

1 changed file:

Changes:

  • compiler/GHC/CmmToAsm/LA64/CodeGen.hs
    ... ... @@ -1784,16 +1784,18 @@ genClz :: Width -> LocalReg -> CmmExpr -> NatM InstrBlock
    1784 1784
     genClz w dst src = do
    
    1785 1785
       platform <- getPlatform
    
    1786 1786
       (reg_x, _, code_x) <- getSomeReg src
    
    1787
    +  tmp <- getNewRegNat II64
    
    1787 1788
       let dst_reg = getRegisterReg platform (CmmLocal dst)
    
    1788 1789
       if w `elem` [W32, W64] then do
    
    1789 1790
         return (code_x `snocOL` CLZ (OpReg w dst_reg) (OpReg w reg_x))
    
    1790 1791
       else if w `elem` [W8, W16] then do
    
    1792
    +    -- Process uniformly according to one data length, W32.
    
    1791 1793
         return (code_x `appOL` toOL
    
    1792 1794
                      [
    
    1793
    -                  MOV (OpReg W64 dst_reg) (OpImm (ImmInt 1)),
    
    1794
    -                  SLL (OpReg W64 dst_reg) (OpReg W64 dst_reg) (OpImm (ImmInt (31-shift))),
    
    1795
    -                  SLL (OpReg W64 reg_x) (OpReg W64 reg_x) (OpImm (ImmInt (32-shift))),
    
    1796
    -                  OR (OpReg W64 dst_reg) (OpReg W64 dst_reg) (OpReg W64 reg_x),
    
    1795
    +                  MOV (OpReg W64 tmp) (OpImm (ImmInt 1)),
    
    1796
    +                  SLL (OpReg W64 tmp) (OpReg W64 tmp) (OpImm (ImmInt (31-shift))),
    
    1797
    +                  SLL (OpReg W64 dst_reg) (OpReg W32 reg_x) (OpImm (ImmInt (32-shift))),
    
    1798
    +                  OR (OpReg W64 dst_reg) (OpReg W64 tmp) (OpReg W64 dst_reg),
    
    1797 1799
                       CLZ (OpReg W64 dst_reg) (OpReg W32 dst_reg)
    
    1798 1800
                      ]
    
    1799 1801
                )
    
    ... ... @@ -1806,16 +1808,17 @@ genCtz :: Width -> LocalReg -> CmmExpr -> NatM InstrBlock
    1806 1808
     genCtz w dst src = do
    
    1807 1809
       platform <- getPlatform
    
    1808 1810
       (reg_x, _, code_x) <- getSomeReg src
    
    1811
    +  tmp <- getNewRegNat II64
    
    1809 1812
       let dst_reg = getRegisterReg platform (CmmLocal dst)
    
    1810 1813
       if w `elem` [W32, W64] then do
    
    1811 1814
         return (code_x `snocOL` CTZ (OpReg w dst_reg) (OpReg w reg_x))
    
    1812 1815
       else if w `elem` [W8, W16] then do
    
    1813 1816
         return (code_x `appOL` toOL
    
    1814 1817
                      [
    
    1815
    -                  MOV (OpReg W64 dst_reg) (OpImm (ImmInt 1)),
    
    1816
    -                  SLL (OpReg W64 dst_reg) (OpReg W64 dst_reg) (OpImm (ImmInt shift)),
    
    1817
    -                  BSTRPICK II64 (OpReg W64 reg_x) (OpReg W64 reg_x) (OpImm (ImmInt (shift-1))) (OpImm (ImmInt 0)),
    
    1818
    -                  OR  (OpReg W64 dst_reg) (OpReg W64 dst_reg) (OpReg W64 reg_x),
    
    1818
    +                  MOV (OpReg W64 tmp) (OpImm (ImmInt 1)),
    
    1819
    +                  SLL (OpReg W64 tmp) (OpReg W64 tmp) (OpImm (ImmInt shift)),
    
    1820
    +                  BSTRPICK II64 (OpReg W64 dst_reg) (OpReg W64 reg_x) (OpImm (ImmInt (shift-1))) (OpImm (ImmInt 0)),
    
    1821
    +                  OR  (OpReg W64 dst_reg) (OpReg W64 dst_reg) (OpReg W64 tmp),
    
    1819 1822
                       CTZ (OpReg W64 dst_reg) (OpReg W64 dst_reg)
    
    1820 1823
                      ]
    
    1821 1824
                )