aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2018-04-03 16:59:21 +0200
committerUros Bizjak <uros@gcc.gnu.org>2018-04-03 16:59:21 +0200
commit3bbeebd4d1ed20f1031d69e8ab646c687d58ee77 (patch)
tree19bc8e63f17d9e4c7c667ea572f12b076aeda673
parentd2d0710e1a88ec2a97939ab3ee87a84d1f62720a (diff)
downloadgcc-3bbeebd4d1ed20f1031d69e8ab646c687d58ee77.zip
gcc-3bbeebd4d1ed20f1031d69e8ab646c687d58ee77.tar.gz
gcc-3bbeebd4d1ed20f1031d69e8ab646c687d58ee77.tar.bz2
i386.c (emit_i387_cw_initialization): Always use logic instructions when changing rounding bits to preserve precision...
* config/i386/i386.c (emit_i387_cw_initialization): Always use logic instructions when changing rounding bits to preserve precision bits in the x87 control word. From-SVN: r259034
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/i386/i386.c86
2 files changed, 31 insertions, 61 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bac81f8..f1030b4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-04-03 Uros Bizjak <ubizjak@gmail.com>
+
+ * config/i386/i386.c (emit_i387_cw_initialization): Always use logic
+ instructions when changing rounding bits to preserve precision bits
+ in the x87 control word.
+
2018-04-03 Martin Liska <mliska@suse.cz>
PR tree-optimization/82491
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 337545f..44ef60e 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -19678,72 +19678,36 @@ emit_i387_cw_initialization (int mode)
emit_insn (gen_x86_fnstcw_1 (stored_mode));
emit_move_insn (reg, copy_rtx (stored_mode));
- if (TARGET_64BIT || TARGET_PARTIAL_REG_STALL
- || optimize_insn_for_size_p ())
- {
- switch (mode)
- {
- case I387_CW_TRUNC:
- /* round toward zero (truncate) */
- emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0c00)));
- slot = SLOT_CW_TRUNC;
- break;
-
- case I387_CW_FLOOR:
- /* round down toward -oo */
- emit_insn (gen_andhi3 (reg, reg, GEN_INT (~0x0c00)));
- emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0400)));
- slot = SLOT_CW_FLOOR;
- break;
-
- case I387_CW_CEIL:
- /* round up toward +oo */
- emit_insn (gen_andhi3 (reg, reg, GEN_INT (~0x0c00)));
- emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0800)));
- slot = SLOT_CW_CEIL;
- break;
-
- case I387_CW_MASK_PM:
- /* mask precision exception for nearbyint() */
- emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0020)));
- slot = SLOT_CW_MASK_PM;
- break;
-
- default:
- gcc_unreachable ();
- }
- }
- else
+ switch (mode)
{
- switch (mode)
- {
- case I387_CW_TRUNC:
- /* round toward zero (truncate) */
- emit_insn (gen_insvsi_1 (reg, GEN_INT (0xc)));
- slot = SLOT_CW_TRUNC;
- break;
+ case I387_CW_TRUNC:
+ /* round toward zero (truncate) */
+ emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0c00)));
+ slot = SLOT_CW_TRUNC;
+ break;
- case I387_CW_FLOOR:
- /* round down toward -oo */
- emit_insn (gen_insvsi_1 (reg, GEN_INT (0x4)));
- slot = SLOT_CW_FLOOR;
- break;
+ case I387_CW_FLOOR:
+ /* round down toward -oo */
+ emit_insn (gen_andhi3 (reg, reg, GEN_INT (~0x0c00)));
+ emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0400)));
+ slot = SLOT_CW_FLOOR;
+ break;
- case I387_CW_CEIL:
- /* round up toward +oo */
- emit_insn (gen_insvsi_1 (reg, GEN_INT (0x8)));
- slot = SLOT_CW_CEIL;
- break;
+ case I387_CW_CEIL:
+ /* round up toward +oo */
+ emit_insn (gen_andhi3 (reg, reg, GEN_INT (~0x0c00)));
+ emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0800)));
+ slot = SLOT_CW_CEIL;
+ break;
- case I387_CW_MASK_PM:
- /* mask precision exception for nearbyint() */
- emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0020)));
- slot = SLOT_CW_MASK_PM;
- break;
+ case I387_CW_MASK_PM:
+ /* mask precision exception for nearbyint() */
+ emit_insn (gen_iorhi3 (reg, reg, GEN_INT (0x0020)));
+ slot = SLOT_CW_MASK_PM;
+ break;
- default:
- gcc_unreachable ();
- }
+ default:
+ gcc_unreachable ();
}
gcc_assert (slot < MAX_386_STACK_LOCALS);