Mesa (main): lima/ppir: refactor bitcopy to use unsigned char

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 11 22:03:20 UTC 2022


Module: Mesa
Branch: main
Commit: 0f9756f4808739c8b18e62e28bdbb430af735c67
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f9756f4808739c8b18e62e28bdbb430af735c67

Author: Erico Nunes <nunes.erico at gmail.com>
Date:   Sat Feb  5 11:14:36 2022 +0100

lima/ppir: refactor bitcopy to use unsigned char

This code does not work as expected when built with clang and
-fstrict-aliasing.
Redefine it in unsigned char operations so that it does not
violate strict aliasing rules.

Signed-off-by: Erico Nunes <nunes.erico at gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul at gmail.com>
Cc: 22.0 <mesa-stable>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14894>

---

 src/gallium/drivers/lima/ir/pp/codegen.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/lima/ir/pp/codegen.c b/src/gallium/drivers/lima/ir/pp/codegen.c
index 6998fbb5287..6f3912d98e2 100644
--- a/src/gallium/drivers/lima/ir/pp/codegen.c
+++ b/src/gallium/drivers/lima/ir/pp/codegen.c
@@ -713,13 +713,13 @@ static int get_instr_encode_size(ppir_instr *instr)
 
 static void bitcopy(void *dst, int dst_offset, void *src, int src_size)
 {
-   int off1 = dst_offset & 0x1f;
-   uint32_t *cpy_dst = dst, *cpy_src = src;
+   unsigned char *cpy_dst = dst, *cpy_src = src;
+   int off1 = dst_offset & 0x07;
 
-   cpy_dst += (dst_offset >> 5);
+   cpy_dst += (dst_offset >> 3);
 
    if (off1) {
-      int off2 = 32 - off1;
+      int off2 = 0x08 - off1;
       int cpy_size = 0;
       while (1) {
          *cpy_dst |= *cpy_src << off1;



More information about the mesa-commit mailing list