diff options
author | Ian Lance Taylor <iant@golang.org> | 2023-06-26 09:57:21 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2023-06-26 09:57:21 -0700 |
commit | aa1e672b5d99102b03eb5fb9c51609c45f62bff7 (patch) | |
tree | 886212591b1c9d127eaaf234a4a2e22452ea384a /gcc/simplify-rtx.cc | |
parent | 97e31a0a2a2d2273687fcdb4e5416aab1a2186e1 (diff) | |
parent | 3a39a31b8ae9c6465434aefa657f7fcc86f905c0 (diff) | |
download | gcc-devel/gccgo.zip gcc-devel/gccgo.tar.gz gcc-devel/gccgo.tar.bz2 |
Merge from trunk revision 3a39a31b8ae9c6465434aefa657f7fcc86f905c0.devel/gccgo
Diffstat (limited to 'gcc/simplify-rtx.cc')
-rw-r--r-- | gcc/simplify-rtx.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc index 1b58144..99cbdd4 100644 --- a/gcc/simplify-rtx.cc +++ b/gcc/simplify-rtx.cc @@ -7758,6 +7758,38 @@ simplify_context::simplify_subreg (machine_mode outermode, rtx op, return CONST0_RTX (outermode); } + /* Optimize SUBREGS of scalar integral ASHIFT by a valid constant. */ + if (GET_CODE (op) == ASHIFT + && SCALAR_INT_MODE_P (innermode) + && CONST_INT_P (XEXP (op, 1)) + && INTVAL (XEXP (op, 1)) > 0 + && known_gt (GET_MODE_BITSIZE (innermode), INTVAL (XEXP (op, 1)))) + { + HOST_WIDE_INT val = INTVAL (XEXP (op, 1)); + /* A lowpart SUBREG of a ASHIFT by a constant may fold to zero. */ + if (known_eq (subreg_lowpart_offset (outermode, innermode), byte) + && known_le (GET_MODE_BITSIZE (outermode), val)) + return CONST0_RTX (outermode); + /* Optimize the highpart SUBREG of a suitable ASHIFT (ZERO_EXTEND). */ + if (GET_CODE (XEXP (op, 0)) == ZERO_EXTEND + && GET_MODE (XEXP (XEXP (op, 0), 0)) == outermode + && known_eq (GET_MODE_BITSIZE (outermode), val) + && known_eq (GET_MODE_BITSIZE (innermode), 2 * val) + && known_eq (subreg_highpart_offset (outermode, innermode), byte)) + return XEXP (XEXP (op, 0), 0); + } + + /* Attempt to simplify WORD_MODE SUBREGs of bitwise expressions. */ + if (outermode == word_mode + && (GET_CODE (op) == IOR || GET_CODE (op) == XOR || GET_CODE (op) == AND) + && SCALAR_INT_MODE_P (innermode)) + { + rtx op0 = simplify_subreg (outermode, XEXP (op, 0), innermode, byte); + rtx op1 = simplify_subreg (outermode, XEXP (op, 1), innermode, byte); + if (op0 && op1) + return simplify_gen_binary (GET_CODE (op), outermode, op0, op1); + } + scalar_int_mode int_outermode, int_innermode; if (is_a <scalar_int_mode> (outermode, &int_outermode) && is_a <scalar_int_mode> (innermode, &int_innermode) |