• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision8cf9a3d3f7a4b95f33e0bda5416b9c93ec887dd3 (tree)
Time2017-01-14 04:47:29
AuthorRichard Henderson <rth@twid...>
CommiterRichard Henderson

Log Message

tcg/aarch64: Fix tcg_out_movi

There were some patterns, like 0x0000_ffff_ffff_00ff, for which we
would select to begin a multi-insn sequence with MOVN, but would
fail to set the 0x0000 lane back from 0xffff.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Message-Id: <20161207180727.6286-3-rth@twiddle.net>

Change Summary

Incremental Difference

--- a/tcg/aarch64/tcg-target.inc.c
+++ b/tcg/aarch64/tcg-target.inc.c
@@ -580,11 +580,9 @@ static void tcg_out_logicali(TCGContext *s, AArch64Insn insn, TCGType ext,
580580 static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,
581581 tcg_target_long value)
582582 {
583- AArch64Insn insn;
584583 int i, wantinv, shift;
585584 tcg_target_long svalue = value;
586585 tcg_target_long ivalue = ~value;
587- tcg_target_long imask;
588586
589587 /* For 32-bit values, discard potential garbage in value. For 64-bit
590588 values within [2**31, 2**32-1], we can create smaller sequences by
@@ -630,42 +628,35 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,
630628
631629 /* Would it take fewer insns to begin with MOVN? For the value and its
632630 inverse, count the number of 16-bit lanes that are 0. */
633- for (i = wantinv = imask = 0; i < 64; i += 16) {
631+ for (i = wantinv = 0; i < 64; i += 16) {
634632 tcg_target_long mask = 0xffffull << i;
635- if ((value & mask) == 0) {
636- wantinv -= 1;
637- }
638- if ((ivalue & mask) == 0) {
639- wantinv += 1;
640- imask |= mask;
641- }
633+ wantinv -= ((value & mask) == 0);
634+ wantinv += ((ivalue & mask) == 0);
642635 }
643636
644- /* If we had more 0xffff than 0x0000, invert VALUE and use MOVN. */
645- insn = I3405_MOVZ;
646- if (wantinv > 0) {
647- value = ivalue;
648- insn = I3405_MOVN;
649- }
650-
651- /* Find the lowest lane that is not 0x0000. */
652- shift = ctz64(value) & (63 & -16);
653- tcg_out_insn_3405(s, insn, type, rd, value >> shift, shift);
654-
655- if (wantinv > 0) {
656- /* Re-invert the value, so MOVK sees non-inverted bits. */
657- value = ~value;
658- /* Clear out all the 0xffff lanes. */
659- value ^= imask;
660- }
661- /* Clear out the lane that we just set. */
662- value &= ~(0xffffUL << shift);
663-
664- /* Iterate until all lanes have been set, and thus cleared from VALUE. */
665- while (value) {
637+ if (wantinv <= 0) {
638+ /* Find the lowest lane that is not 0x0000. */
666639 shift = ctz64(value) & (63 & -16);
667- tcg_out_insn(s, 3405, MOVK, type, rd, value >> shift, shift);
640+ tcg_out_insn(s, 3405, MOVZ, type, rd, value >> shift, shift);
641+ /* Clear out the lane that we just set. */
668642 value &= ~(0xffffUL << shift);
643+ /* Iterate until all non-zero lanes have been processed. */
644+ while (value) {
645+ shift = ctz64(value) & (63 & -16);
646+ tcg_out_insn(s, 3405, MOVK, type, rd, value >> shift, shift);
647+ value &= ~(0xffffUL << shift);
648+ }
649+ } else {
650+ /* Like above, but with the inverted value and MOVN to start. */
651+ shift = ctz64(ivalue) & (63 & -16);
652+ tcg_out_insn(s, 3405, MOVN, type, rd, ivalue >> shift, shift);
653+ ivalue &= ~(0xffffUL << shift);
654+ while (ivalue) {
655+ shift = ctz64(ivalue) & (63 & -16);
656+ /* Provide MOVK with the non-inverted value. */
657+ tcg_out_insn(s, 3405, MOVK, type, rd, ~(ivalue >> shift), shift);
658+ ivalue &= ~(0xffffUL << shift);
659+ }
669660 }
670661 }
671662