]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[LRA]: Fix mode of subreg of const in the const pool
authorVladimir N. Makarov <vmakarov@redhat.com>
Tue, 28 Apr 2026 12:51:13 +0000 (08:51 -0400)
committerVladimir N. Makarov <vmakarov@redhat.com>
Tue, 28 Apr 2026 18:09:59 +0000 (14:09 -0400)
When LRA puts a constant which is part of subreg, it uses wrong mode for
subreg of the pool memory.  The patch fixes this.

gcc/ChangeLog:

* lra-constraints.cc (curr_insn_transform): When recreating subreg
of a const put in pool, use the original subreg mode.

gcc/lra-constraints.cc

index 9a400c21b7e14f26ca4b7cbc55d154676c903f7e..d6056cf7accb776c91000fa1f66750322cf38366 100644 (file)
@@ -4715,7 +4715,7 @@ curr_insn_transform (bool check_only_p)
        char c;
        rtx op = *curr_id->operand_loc[i];
        rtx subreg = NULL_RTX;
-       machine_mode mode = curr_operand_mode[i];
+       machine_mode op_mode = curr_operand_mode[i], mode = op_mode;
 
        if (GET_CODE (op) == SUBREG)
          {
@@ -4733,7 +4733,7 @@ curr_insn_transform (bool check_only_p)
 
            change_p = true;
            if (subreg != NULL_RTX)
-             tem = gen_rtx_SUBREG (mode, tem, SUBREG_BYTE (subreg));
+             tem = gen_rtx_SUBREG (op_mode, tem, SUBREG_BYTE (subreg));
 
            *curr_id->operand_loc[i] = tem;
            lra_update_dup (curr_id, i);