mirrored from git://gcc.gnu.org/git/gcc.git
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: Bugfix for rvv bool mode precision adjustment
Fix the bug of the rvv bool mode precision with the adjustment. The bits size of vbool*_t will be adjusted to [1, 2, 4, 8, 16, 32, 64] according to the rvv spec 1.0 isa. The adjusted mode precison of vbool*_t will help underlying pass to make the right decision for both the correctness and optimization. Given below sample code: void test_1(int8_t * restrict in, int8_t * restrict out) { vbool8_t v2 = *(vbool8_t*)in; vbool16_t v5 = *(vbool16_t*)in; *(vbool16_t*)(out + 200) = v5; *(vbool8_t*)(out + 100) = v2; } Before the precision adjustment: addi a4,a1,100 vsetvli a5,zero,e8,m1,ta,ma addi a1,a1,200 vlm.v v24,0(a0) vsm.v v24,0(a4) // Need one vsetvli and vlm.v for correctness here. vsm.v v24,0(a1) After the precision adjustment: csrr t0,vlenb slli t1,t0,1 csrr a3,vlenb sub sp,sp,t1 slli a4,a3,1 add a4,a4,sp sub a3,a4,a3 vsetvli a5,zero,e8,m1,ta,ma addi a2,a1,200 vlm.v v24,0(a0) vsm.v v24,0(a3) addi a1,a1,100 vsetvli a4,zero,e8,mf2,ta,ma csrr t0,vlenb vlm.v v25,0(a3) vsm.v v25,0(a2) slli t1,t0,1 vsetvli a5,zero,e8,m1,ta,ma vsm.v v24,0(a1) add sp,sp,t1 jr ra However, there may be some optimization opportunates after the mode precision adjustment. It can be token care of in the RISC-V backend in the underlying separted PR(s). gcc/ChangeLog: PR target/108185 PR target/108654 * config/riscv/riscv-modes.def (ADJUST_PRECISION): Adjust VNx*BI modes. * config/riscv/riscv.cc (riscv_v_adjust_precision): New. * config/riscv/riscv.h (riscv_v_adjust_precision): New. * genmodes.cc (adj_precision): New. (ADJUST_PRECISION): New. (emit_mode_adjustments): Handle ADJUST_PRECISION. gcc/testsuite/ChangeLog: PR target/108185 PR target/108654 * gcc.target/riscv/rvv/base/pr108185-1.c: New test. * gcc.target/riscv/rvv/base/pr108185-2.c: New test. * gcc.target/riscv/rvv/base/pr108185-3.c: New test. * gcc.target/riscv/rvv/base/pr108185-4.c: New test. * gcc.target/riscv/rvv/base/pr108185-5.c: New test. * gcc.target/riscv/rvv/base/pr108185-6.c: New test. * gcc.target/riscv/rvv/base/pr108185-7.c: New test. * gcc.target/riscv/rvv/base/pr108185-8.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com> Co-authored-by: Ju-Zhe Zhong <juzhe.zhong@rivai.ai>
- Loading branch information
1 parent
59a72ac
commit 247cacc
Showing
12 changed files
with
600 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ | ||
|
||
#include "riscv_vector.h" | ||
|
||
void | ||
test_vbool1_then_vbool2(int8_t * restrict in, int8_t * restrict out) { | ||
vbool1_t v1 = *(vbool1_t*)in; | ||
vbool2_t v2 = *(vbool2_t*)in; | ||
|
||
*(vbool1_t*)(out + 100) = v1; | ||
*(vbool2_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool1_then_vbool4(int8_t * restrict in, int8_t * restrict out) { | ||
vbool1_t v1 = *(vbool1_t*)in; | ||
vbool4_t v2 = *(vbool4_t*)in; | ||
|
||
*(vbool1_t*)(out + 100) = v1; | ||
*(vbool4_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool1_then_vbool8(int8_t * restrict in, int8_t * restrict out) { | ||
vbool1_t v1 = *(vbool1_t*)in; | ||
vbool8_t v2 = *(vbool8_t*)in; | ||
|
||
*(vbool1_t*)(out + 100) = v1; | ||
*(vbool8_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool1_then_vbool16(int8_t * restrict in, int8_t * restrict out) { | ||
vbool1_t v1 = *(vbool1_t*)in; | ||
vbool16_t v2 = *(vbool16_t*)in; | ||
|
||
*(vbool1_t*)(out + 100) = v1; | ||
*(vbool16_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool1_then_vbool32(int8_t * restrict in, int8_t * restrict out) { | ||
vbool1_t v1 = *(vbool1_t*)in; | ||
vbool32_t v2 = *(vbool32_t*)in; | ||
|
||
*(vbool1_t*)(out + 100) = v1; | ||
*(vbool32_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool1_then_vbool64(int8_t * restrict in, int8_t * restrict out) { | ||
vbool1_t v1 = *(vbool1_t*)in; | ||
vbool64_t v2 = *(vbool64_t*)in; | ||
|
||
*(vbool1_t*)(out + 100) = v1; | ||
*(vbool64_t*)(out + 200) = v2; | ||
} | ||
|
||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 6 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ | ||
/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 18 } } */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ | ||
|
||
#include "riscv_vector.h" | ||
|
||
void | ||
test_vbool2_then_vbool1(int8_t * restrict in, int8_t * restrict out) { | ||
vbool2_t v1 = *(vbool2_t*)in; | ||
vbool1_t v2 = *(vbool1_t*)in; | ||
|
||
*(vbool2_t*)(out + 100) = v1; | ||
*(vbool1_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool2_then_vbool4(int8_t * restrict in, int8_t * restrict out) { | ||
vbool2_t v1 = *(vbool2_t*)in; | ||
vbool4_t v2 = *(vbool4_t*)in; | ||
|
||
*(vbool2_t*)(out + 100) = v1; | ||
*(vbool4_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool2_then_vbool8(int8_t * restrict in, int8_t * restrict out) { | ||
vbool2_t v1 = *(vbool2_t*)in; | ||
vbool8_t v2 = *(vbool8_t*)in; | ||
|
||
*(vbool2_t*)(out + 100) = v1; | ||
*(vbool8_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool2_then_vbool16(int8_t * restrict in, int8_t * restrict out) { | ||
vbool2_t v1 = *(vbool2_t*)in; | ||
vbool16_t v2 = *(vbool16_t*)in; | ||
|
||
*(vbool2_t*)(out + 100) = v1; | ||
*(vbool16_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool2_then_vbool32(int8_t * restrict in, int8_t * restrict out) { | ||
vbool2_t v1 = *(vbool2_t*)in; | ||
vbool32_t v2 = *(vbool32_t*)in; | ||
|
||
*(vbool2_t*)(out + 100) = v1; | ||
*(vbool32_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool2_then_vbool64(int8_t * restrict in, int8_t * restrict out) { | ||
vbool2_t v1 = *(vbool2_t*)in; | ||
vbool64_t v2 = *(vbool64_t*)in; | ||
|
||
*(vbool2_t*)(out + 100) = v1; | ||
*(vbool64_t*)(out + 200) = v2; | ||
} | ||
|
||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 6 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ | ||
/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 17 } } */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ | ||
|
||
#include "riscv_vector.h" | ||
|
||
void | ||
test_vbool4_then_vbool1(int8_t * restrict in, int8_t * restrict out) { | ||
vbool4_t v1 = *(vbool4_t*)in; | ||
vbool1_t v2 = *(vbool1_t*)in; | ||
|
||
*(vbool4_t*)(out + 100) = v1; | ||
*(vbool1_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool4_then_vbool2(int8_t * restrict in, int8_t * restrict out) { | ||
vbool4_t v1 = *(vbool4_t*)in; | ||
vbool2_t v2 = *(vbool2_t*)in; | ||
|
||
*(vbool4_t*)(out + 100) = v1; | ||
*(vbool2_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool4_then_vbool8(int8_t * restrict in, int8_t * restrict out) { | ||
vbool4_t v1 = *(vbool4_t*)in; | ||
vbool8_t v2 = *(vbool8_t*)in; | ||
|
||
*(vbool4_t*)(out + 100) = v1; | ||
*(vbool8_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool4_then_vbool16(int8_t * restrict in, int8_t * restrict out) { | ||
vbool4_t v1 = *(vbool4_t*)in; | ||
vbool16_t v2 = *(vbool16_t*)in; | ||
|
||
*(vbool4_t*)(out + 100) = v1; | ||
*(vbool16_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool4_then_vbool32(int8_t * restrict in, int8_t * restrict out) { | ||
vbool4_t v1 = *(vbool4_t*)in; | ||
vbool32_t v2 = *(vbool32_t*)in; | ||
|
||
*(vbool4_t*)(out + 100) = v1; | ||
*(vbool32_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool4_then_vbool64(int8_t * restrict in, int8_t * restrict out) { | ||
vbool4_t v1 = *(vbool4_t*)in; | ||
vbool64_t v2 = *(vbool64_t*)in; | ||
|
||
*(vbool4_t*)(out + 100) = v1; | ||
*(vbool64_t*)(out + 200) = v2; | ||
} | ||
|
||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 6 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ | ||
/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 16 } } */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ | ||
|
||
#include "riscv_vector.h" | ||
|
||
void | ||
test_vbool8_then_vbool1(int8_t * restrict in, int8_t * restrict out) { | ||
vbool8_t v1 = *(vbool8_t*)in; | ||
vbool1_t v2 = *(vbool1_t*)in; | ||
|
||
*(vbool8_t*)(out + 100) = v1; | ||
*(vbool1_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool8_then_vbool2(int8_t * restrict in, int8_t * restrict out) { | ||
vbool8_t v1 = *(vbool8_t*)in; | ||
vbool2_t v2 = *(vbool2_t*)in; | ||
|
||
*(vbool8_t*)(out + 100) = v1; | ||
*(vbool2_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool8_then_vbool4(int8_t * restrict in, int8_t * restrict out) { | ||
vbool8_t v1 = *(vbool8_t*)in; | ||
vbool4_t v2 = *(vbool4_t*)in; | ||
|
||
*(vbool8_t*)(out + 100) = v1; | ||
*(vbool4_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool8_then_vbool16(int8_t * restrict in, int8_t * restrict out) { | ||
vbool8_t v1 = *(vbool8_t*)in; | ||
vbool16_t v2 = *(vbool16_t*)in; | ||
|
||
*(vbool8_t*)(out + 100) = v1; | ||
*(vbool16_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool8_then_vbool32(int8_t * restrict in, int8_t * restrict out) { | ||
vbool8_t v1 = *(vbool8_t*)in; | ||
vbool32_t v2 = *(vbool32_t*)in; | ||
|
||
*(vbool8_t*)(out + 100) = v1; | ||
*(vbool32_t*)(out + 200) = v2; | ||
} | ||
|
||
void | ||
test_vbool8_then_vbool64(int8_t * restrict in, int8_t * restrict out) { | ||
vbool8_t v1 = *(vbool8_t*)in; | ||
vbool64_t v2 = *(vbool64_t*)in; | ||
|
||
*(vbool8_t*)(out + 100) = v1; | ||
*(vbool64_t*)(out + 200) = v2; | ||
} | ||
|
||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 6 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ | ||
/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ | ||
/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 15 } } */ |
Oops, something went wrong.