]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
xtensa: Optimize ctzsi2 and ffssi2 a bit
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Thu, 12 Jan 2023 04:26:42 +0000 (13:26 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Thu, 12 Jan 2023 12:44:06 +0000 (04:44 -0800)
This patch saves one byte when the Code Density Option is enabled,

gcc/ChangeLog:

* config/xtensa/xtensa.md (ctzsi2, ffssi2):
Rearrange the emitting codes.

gcc/config/xtensa/xtensa.md

index b4989832169c7c23309e99f34a3fb01718a3d2ce..764da63f91cb7c02eba6bf648ebc0bc33d16dd5e 100644 (file)
   emit_insn (gen_negsi2 (temp, operands[1]));
   emit_insn (gen_andsi3 (temp, temp, operands[1]));
   emit_insn (gen_clzsi2 (temp, temp));
-  emit_insn (gen_negsi2 (temp, temp));
-  emit_insn (gen_addsi3 (operands[0], temp, GEN_INT (31)));
+  emit_move_insn (operands[0], GEN_INT (31));
+  emit_insn (gen_subsi3 (operands[0], operands[0], temp));
   DONE;
 })
 
   emit_insn (gen_negsi2 (temp, operands[1]));
   emit_insn (gen_andsi3 (temp, temp, operands[1]));
   emit_insn (gen_clzsi2 (temp, temp));
-  emit_insn (gen_negsi2 (temp, temp));
-  emit_insn (gen_addsi3 (operands[0], temp, GEN_INT (32)));
+  emit_move_insn (operands[0], GEN_INT (32));
+  emit_insn (gen_subsi3 (operands[0], operands[0], temp));
   DONE;
 })