Anonymous avatar Anonymous committed 058e97b

Optimize zero-extend and sign-extend in _ensure_result_bit_extension
and add PPC64 support.

Comments (0)

Files changed (1)

pypy/jit/backend/ppc/ppcgen/ppc_assembler.py

         assert 0, "not supported location"
 
     def _ensure_result_bit_extension(self, resloc, size, signed):
-        if size == 4:
-            return
         if size == 1:
             if not signed: #unsigned char
-                self.mc.load_imm(r.r0, 0xFF)
-                self.mc.and_(resloc.value, resloc.value, r.r0.value)
+                if IS_PPC32:
+                    self.mc.load_imm(r.r0, 0xFF)
+                    self.mc.and_(resloc.value, resloc.value, r.r0.value)
+                else:
+                    self.mc.rldicl(resloc.value, resloc.value, 0, 56)
             else:
-                self.mc.load_imm(r.r0, 24)
-                self.mc.slw(resloc.value, resloc.value, r.r0.value)
-                self.mc.sraw(resloc.value, resloc.value, r.r0.value)
+                self.mc.extsb(resloc.value, resloc.value)
         elif size == 2:
             if not signed:
-                self.mc.load_imm(r.r0, 16)
-                self.mc.slw(resloc.value, resloc.value, r.r0.value)
-                self.mc.srw(resloc.value, resloc.value, r.r0.value)
+                if IS_PPC_32:
+                    self.mc.load_imm(r.r0, 16)
+                    self.mc.slw(resloc.value, resloc.value, r.r0.value)
+                    self.mc.srw(resloc.value, resloc.value, r.r0.value)
+                else:
+                    self.mc.rldicl(resloc.value, resloc.value, 0, 48)
             else:
-                self.mc.load_imm(r.r0, 16)
-                self.mc.slw(resloc.value, resloc.value, r.r0.value)
-                self.mc.sraw(resloc.value, resloc.value, r.r0.value)
+                self.mc.extsh(resloc.value, resloc.value)
+        elif size == 4:
+            if not signed:
+                self.mc.rldicl(resloc.value, resloc.value, 0, 32)
+            else:
+                self.mc.extsw(resloc.value, resloc.value)
 
     def mark_gc_roots(self, force_index, use_copy_area=False):
         if force_index < 0:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.