Skip to content
Snippets Groups Projects
Commit 7d5d2b87 authored by YunQiang Su's avatar YunQiang Su Committed by YunQiang Su
Browse files

expmed: TRUNCATE value1 if needed in store_bit_field_using_insv

PR target/113179.

In `store_bit_field_using_insv`, we just use SUBREG if value_mode
>= op_mode, while in some ports, a sign_extend will be needed,
such as MIPS64:
  If either GPR rs or GPR rt does not contain sign-extended 32-bit
  values (bits 63..31 equal), then the result of the operation is
  UNPREDICTABLE.

The problem happens for the code like:
  struct xx {
        int a:4;
        int b:24;
        int c:3;
        int d:1;
  };

  void xx (struct xx *a, long long b) {
        a->d = b;
  }

In the above code, the hard register contains `b`, may be note well
sign-extended.

gcc/
	PR target/113179
	* expmed.cc(store_bit_field_using_insv): TRUNCATE value1 if
	needed.

gcc/testsuite
	PR target/113179
	* gcc.target/mips/pr113179.c: New tests.
parent 70d30dd6
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment