aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-09-05 22:32:55 +0200
committerJim Wilson <wilson@gcc.gnu.org>2019-09-05 13:32:55 -0700
commit36ec3f57d305e343ad1bbffa53e3484661a176a6 (patch)
tree2865b2618fabe876bb58c8f86dd2c67192a09778 /gcc/config
parent3c0f026505aca54c200b36870256c886b05eb4ff (diff)
downloadgcc-36ec3f57d305e343ad1bbffa53e3484661a176a6.zip
gcc-36ec3f57d305e343ad1bbffa53e3484661a176a6.tar.gz
gcc-36ec3f57d305e343ad1bbffa53e3484661a176a6.tar.bz2
RISC-V: Fix bad insn splits with paradoxical subregs.
Shifting by more than the size of a SUBREG_REG doesn't work, so we either need to disable splits if an input is paradoxical, or else we need to generate a clean temporary for intermediate results. Jakub wrote the first version of this patch, so gets primary credit for it. gcc/ PR target/91635 * config/riscv/riscv.md (zero_extendsidi2, zero_extendhi<GPR:mode>2, extend<SHORT:mode><SUPERQI:mode>2): Don't split if paradoxical_subreg_p (operands[0]). (*lshrsi3_zero_extend_3+1, *lshrsi3_zero_extend_3+2): Add clobber and use as intermediate value. gcc/testsuite/ PR target/91635 * gcc.c-torture/execute/pr91635.c: New test. * gcc.target/riscv/shift-shift-4.c: New test. * gcc.target/riscv/shift-shift-5.c: New test. Co-Authored-By: Jim Wilson <jimw@sifive.com> From-SVN: r275444
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/riscv/riscv.md30
1 files changed, 21 insertions, 9 deletions
diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 78260fc..744a027 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -1051,7 +1051,9 @@
"@
#
lwu\t%0,%1"
- "&& reload_completed && REG_P (operands[1])"
+ "&& reload_completed
+ && REG_P (operands[1])
+ && !paradoxical_subreg_p (operands[0])"
[(set (match_dup 0)
(ashift:DI (match_dup 1) (const_int 32)))
(set (match_dup 0)
@@ -1068,7 +1070,9 @@
"@
#
lhu\t%0,%1"
- "&& reload_completed && REG_P (operands[1])"
+ "&& reload_completed
+ && REG_P (operands[1])
+ && !paradoxical_subreg_p (operands[0])"
[(set (match_dup 0)
(ashift:GPR (match_dup 1) (match_dup 2)))
(set (match_dup 0)
@@ -1117,7 +1121,9 @@
"@
#
l<SHORT:size>\t%0,%1"
- "&& reload_completed && REG_P (operands[1])"
+ "&& reload_completed
+ && REG_P (operands[1])
+ && !paradoxical_subreg_p (operands[0])"
[(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2)))
(set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 2)))]
{
@@ -1766,15 +1772,20 @@
;; Handle AND with 2^N-1 for N from 12 to XLEN. This can be split into
;; two logical shifts. Otherwise it requires 3 instructions: lui,
;; xor/addi/srli, and.
+
+;; Generating a temporary for the shift output gives better combiner results;
+;; and also fixes a problem where op0 could be a paradoxical reg and shifting
+;; by amounts larger than the size of the SUBREG_REG doesn't work.
(define_split
[(set (match_operand:GPR 0 "register_operand")
(and:GPR (match_operand:GPR 1 "register_operand")
- (match_operand:GPR 2 "p2m1_shift_operand")))]
+ (match_operand:GPR 2 "p2m1_shift_operand")))
+ (clobber (match_operand:GPR 3 "register_operand"))]
""
- [(set (match_dup 0)
+ [(set (match_dup 3)
(ashift:GPR (match_dup 1) (match_dup 2)))
(set (match_dup 0)
- (lshiftrt:GPR (match_dup 0) (match_dup 2)))]
+ (lshiftrt:GPR (match_dup 3) (match_dup 2)))]
{
/* Op2 is a VOIDmode constant, so get the mode size from op1. */
operands[2] = GEN_INT (GET_MODE_BITSIZE (GET_MODE (operands[1]))
@@ -1786,12 +1797,13 @@
(define_split
[(set (match_operand:DI 0 "register_operand")
(and:DI (match_operand:DI 1 "register_operand")
- (match_operand:DI 2 "high_mask_shift_operand")))]
+ (match_operand:DI 2 "high_mask_shift_operand")))
+ (clobber (match_operand:DI 3 "register_operand"))]
"TARGET_64BIT"
- [(set (match_dup 0)
+ [(set (match_dup 3)
(lshiftrt:DI (match_dup 1) (match_dup 2)))
(set (match_dup 0)
- (ashift:DI (match_dup 0) (match_dup 2)))]
+ (ashift:DI (match_dup 3) (match_dup 2)))]
{
operands[2] = GEN_INT (ctz_hwi (INTVAL (operands[2])));
})