freedreno/ir3: Fold const only when the type is float
authorHyunjun Ko <zzoon@igalia.com>
Thu, 7 Nov 2019 05:32:34 +0000 (05:32 +0000)
committerKristian H. Kristensen <hoegsberg@google.com>
Fri, 7 Feb 2020 17:53:48 +0000 (09:53 -0800)
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3737>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3737>

src/freedreno/ir3/ir3_cp.c

index efcefaeb2b2b3ec46e896e25a6e1a29ba3db25de..03bb8cbe091171372f820233f6e846eebc43ae26 100644 (file)
@@ -523,6 +523,17 @@ reg_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr,
                                        (src_reg->array.offset == 0))
                                return false;
 
+                       /* When narrowing constant from 32b to 16b, it seems
+                        * to work only for float. So we should do this only with
+                        * float opcodes.
+                        */
+                       if (src->cat1.dst_type == TYPE_F16) {
+                               if (instr->opc == OPC_MOV && !type_float(instr->cat1.src_type))
+                                       return false;
+                               if (!ir3_cat2_float(instr->opc) && !ir3_cat3_float(instr->opc))
+                                       return false;
+                       }
+
                        src_reg = ir3_reg_clone(instr->block->shader, src_reg);
                        src_reg->flags = new_flags;
                        instr->regs[n+1] = src_reg;