On 26/2/25 22:52, Richard Henderson wrote:
On 2/26/25 13:51, Philippe Mathieu-Daudé wrote:
On 22/2/25 18:41, Richard Henderson wrote:
On 2/20/25 14:17, Philippe Mathieu-Daudé wrote:
@@ -1794,23 +1715,19 @@ void tcg_gen_andi_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
      case -1:
          tcg_gen_mov_i64(ret, arg1);
          return;
-    case 0xff:
-        /* Don't recurse with tcg_gen_ext8u_i64.  */
-        if (TCG_TARGET_HAS_ext8u_i64) {
-            tcg_gen_op2_i64(INDEX_op_ext8u_i64, ret, arg1);
-            return;
-        }
-        break;
-    case 0xffff:
-        if (TCG_TARGET_HAS_ext16u_i64) {
-            tcg_gen_op2_i64(INDEX_op_ext16u_i64, ret, arg1);
-            return;
-        }
-        break;
-    case 0xffffffffu:
-        if (TCG_TARGET_HAS_ext32u_i64) {
-            tcg_gen_op2_i64(INDEX_op_ext32u_i64, ret, arg1);
-            return;
+    default:
+        /*
+         * Canonicalize on extract, if valid.  This aids x86 with its
+         * 2 operand MOVZBL and 2 operand AND, selecting the TCGOpcode +         * which does not require matching operands.  Other backends can +         * trivially expand the extract to AND during code generation.
+         */

Could also use s/0/ofs/ like for 32-bit.

Pardon?  Are you confusing the tcg_gen_andi_{i32,i64} changes
with the tcg_gen_{s}extract_{i32,i64} changes?

This andi_i64 hunk exactly matches the andi_i32 hunk.

I am thinking of handling ofs > 0:

            unsigned ofs = ctz64(arg2);
            int64_t val = arg2 >> ofs;

            if (!(val & (val + 1))) {
                unsigned len = cto64(val);
                if (TCG_TARGET_extract_valid(TCG_TYPE_I64, ofs, len)) {
                    tcg_gen_extract_i64(ret, arg1, ofs, len);
                    return;
                }
            }


This is AND.  There is no shift involved.  If ofs != 0, you cannot use extract.

🤦 right...

Reply via email to