~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/asahi/compiler/agx_optimizer.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
         continue;
87
87
      if (def->saturate)
88
88
         continue;
 
89
      if (ins->op == AGX_OPCODE_FCMPSEL && s >= 2)
 
90
         continue;
 
91
 
 
92
      /* We can fold f2f32 into 32-bit instructions, but we can't fold f2f16
 
93
       * into 16-bit instructions, since the latter would implicitly promote to
 
94
       * a 32-bit instruction which is not exact.
 
95
       */
 
96
      assert(def->src[0].size == AGX_SIZE_32 ||
 
97
             def->src[0].size == AGX_SIZE_16);
 
98
      assert(src.size == AGX_SIZE_32 || src.size == AGX_SIZE_16);
 
99
 
 
100
      if (src.size == AGX_SIZE_16 && def->src[0].size == AGX_SIZE_32)
 
101
         continue;
89
102
 
90
103
      ins->src[s] = agx_compose_float_src(src, def->src[0]);
91
104
   }
111
124
 
112
125
      bool float_src = is_float;
113
126
 
114
 
      /* cmpselsrc takes integer immediates only */
115
 
      if (s >= 2 && I->op == AGX_OPCODE_FCMPSEL)
116
 
         float_src = false;
 
127
      /* fcmpsel takes first 2 as floats specially */
 
128
      if (s < 2 && I->op == AGX_OPCODE_FCMPSEL)
 
129
         float_src = true;
117
130
      if (I->op == AGX_OPCODE_ST_TILE && s == 0)
118
131
         continue;
119
132
      if (I->op == AGX_OPCODE_ZS_EMIT && s != 0)
152
165
   if (use->src[0].neg || use->src[0].abs)
153
166
      return false;
154
167
 
 
168
   /* We can fold f2f16 into 32-bit instructions, but we can't fold f2f32 into
 
169
    * 16-bit instructions, since the latter would implicitly promote to a 32-bit
 
170
    * instruction which is not exact.
 
171
    */
 
172
   assert(use->dest[0].size == AGX_SIZE_32 || use->dest[0].size == AGX_SIZE_16);
 
173
   assert(I->dest[0].size == AGX_SIZE_32 || I->dest[0].size == AGX_SIZE_16);
 
174
 
 
175
   if (I->dest[0].size == AGX_SIZE_16 && use->dest[0].size == AGX_SIZE_32)
 
176
      return false;
 
177
 
155
178
   /* saturate(saturate(x)) = saturate(x) */
156
179
   I->saturate |= use->saturate;
157
180
   I->dest[0] = use->dest[0];
208
231
      agx_optimizer_copyprop(defs, I);
209
232
 
210
233
      /* Propagate fmov down */
211
 
      if (info.is_float)
 
234
      if (info.is_float || I->op == AGX_OPCODE_FCMPSEL)
212
235
         agx_optimizer_fmov(defs, I);
213
236
 
214
237
      /* Inline immediates if we can. TODO: systematic */