Skip to content

Commit fc92d40

Browse files
arcv: Disable *<any_extract...>3 when fusion is available
This define_insn_and_split prevents *zero_extract_fused from being selected. Updated the test. It succeeded despite the fused case not being selected because the right instructions were produced still. Signed-off-by: Michiel Derhaeg <[email protected]>
1 parent a8477b0 commit fc92d40

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

gcc/config/riscv/iterators.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@
218218
(zero_extract "srliw")])
219219
(define_code_attr extract_shift [(sign_extract "ashiftrt")
220220
(zero_extract "lshiftrt")])
221+
(define_code_attr is_zero_extract [(sign_extract "false")
222+
(zero_extract "true")])
221223

222224
;; This code iterator allows the two right shift instructions to be
223225
;; generated from the same template.

gcc/config/riscv/riscv.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3101,6 +3101,7 @@
31013101
;; * Single-bit extraction (SFB)
31023102
;; * Extraction instruction th.ext(u) (XTheadBb)
31033103
;; * lshrsi3_extend_2 (see above)
3104+
;; * Zero extraction fusion (ARC-V)
31043105
(define_insn_and_split "*<any_extract:optab><GPR:mode>3"
31053106
[(set (match_operand:GPR 0 "register_operand" "=r")
31063107
(any_extract:GPR
@@ -3113,6 +3114,8 @@
31133114
&& (INTVAL (operands[2]) == 1))
31143115
&& !TARGET_XTHEADBB
31153116
&& !TARGET_XANDESPERF
3117+
&& !(riscv_is_micro_arch (arcv_rhx100)
3118+
&& <any_extract:is_zero_extract>)
31163119
&& !(TARGET_64BIT
31173120
&& (INTVAL (operands[3]) > 0)
31183121
&& (INTVAL (operands[2]) + INTVAL (operands[3]) == 32))"
@@ -4600,7 +4603,7 @@
46004603
(match_operand:SI 2 "register_operand" "r,r"))
46014604
(match_operand:SI 3 "register_operand" "r,?0"))))
46024605
(clobber (match_scratch:SI 4 "=&r,&r"))]
4603-
"arcv_micro_arch_supports_fusion_p ()
4606+
"riscv_is_micro_arch (arcv_rhx100)
46044607
&& (TARGET_ZMMUL || TARGET_MUL)"
46054608
{
46064609
if (REGNO (operands[0]) == REGNO (operands[3]))

gcc/doc/riscv-mtune.texi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ particular CPU name. Permissible values for this option are:
5252

5353
@samp{arc-v-rmx-100-series},
5454

55+
@samp{arc-v-rhx-100-series},
56+
5557
@samp{generic-ooo},
5658

5759
@samp{size},
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* { dg-do compile } */
22
/* { dg-require-effective-target rv32 } */
33
/* { dg-skip-if "" { *-*-* } { "-g" "-flto" "-O0" "-Oz" "-Os" } } */
4-
/* { dg-options "-mtune=arc-v-rhx-100-series -march=rv32im_zbs -mabi=ilp32" } */
4+
/* { dg-options "-mtune=arc-v-rhx-100-series -march=rv32im_zbs -mabi=ilp32 -dp" } */
55

66
#define bit_extract(x,start,amt) (((x)>>(start)) & (~(0xffffffff << (amt))))
77

@@ -11,4 +11,4 @@ f (int x)
1111
return bit_extract(x,10,14) + bit_extract(x,1,1);
1212
}
1313

14-
/* { dg-final { scan-assembler {\sslli\s([ast][0-9]+),a0,8\n\ssrli\s([ast][0-9]+),\1,18\n\sbexti\sa0,a0,1\n\sadd\sa0,\2,a0\n} } } */
14+
/* { dg-final { scan-assembler {\sslli\s([ast][0-9]+),a0,8.*zero_extract_fused\n\ssrli\s([ast][0-9]+),\1,18\n\sbexti\sa0,a0,1.*\n\sadd\sa0,\2,a0.*\n} } } */

0 commit comments

Comments
 (0)