This patch makes parallel changes to store_bit_field_1 and
extract_bit_field_1 to skip some register shortcuts if
-fstrict-volatile-bitfields applies. By itself, it doesn't fix any of
the new test cases added in part 5, but it's required in conjunction
with part 3 to make the new volatile-bitfields-3.c test pass on some
targets (specifically, x86_64).
This part of the patch series has already been approved, but since it's
probably not useful without the other pieces, I'm deferring checking it
in for now.
-Sandra
2013-06-16 Sandra Loosemore <san...@codesourcery.com>
gcc/
* expmed.c (store_bit_field_1): Skip both cheap register alternatives
if -fstrict-volatile-bitfields applies, not just the first one.
(extract_bit_field_1): Likewise.
Index: gcc/expmed.c
===================================================================
--- gcc/expmed.c (revision 199963)
+++ gcc/expmed.c (working copy)
@@ -810,15 +810,15 @@ store_bit_field_1 (rtx str_rtx, unsigned
return true;
/* If OP0 is a memory, try copying it to a register and seeing if a
- cheap register alternative is available. */
- if (MEM_P (op0))
+ cheap register alternative is available. Do not try these tricks if
+ -fstrict-volatile-bitfields is in effect, since they may not respect
+ the mode of the access. */
+ if (MEM_P (op0)
+ && !(MEM_VOLATILE_P (op0)
+ && flag_strict_volatile_bitfields > 0))
{
- /* Do not use unaligned memory insvs for volatile bitfields when
- -fstrict-volatile-bitfields is in effect. */
- if (!(MEM_VOLATILE_P (op0)
- && flag_strict_volatile_bitfields > 0)
- && get_best_mem_extraction_insn (&insv, EP_insv, bitsize, bitnum,
- fieldmode)
+ if (get_best_mem_extraction_insn (&insv, EP_insv, bitsize, bitnum,
+ fieldmode)
&& store_bit_field_using_insv (&insv, op0, bitsize, bitnum, value))
return true;
@@ -1592,14 +1592,14 @@ extract_bit_field_1 (rtx str_rtx, unsign
}
/* If OP0 is a memory, try copying it to a register and seeing if a
- cheap register alternative is available. */
- if (MEM_P (op0))
+ cheap register alternative is available. Do not try these tricks if
+ -fstrict-volatile-bitfields is in effect, since they may not respect
+ the mode of the access. */
+ if (MEM_P (op0)
+ && !(MEM_VOLATILE_P (op0) && flag_strict_volatile_bitfields > 0))
{
- /* Do not use extv/extzv for volatile bitfields when
- -fstrict-volatile-bitfields is in effect. */
- if (!(MEM_VOLATILE_P (op0) && flag_strict_volatile_bitfields > 0)
- && get_best_mem_extraction_insn (&extv, pattern, bitsize, bitnum,
- tmode))
+ if (get_best_mem_extraction_insn (&extv, pattern, bitsize, bitnum,
+ tmode))
{
rtx result = extract_bit_field_using_extv (&extv, op0, bitsize,
bitnum, unsignedp,