diff options
author | Simon Tatham <simon.tatham@arm.com> | 2020-01-09 10:49:41 +0000 |
---|---|---|
committer | Simon Tatham <simon.tatham@arm.com> | 2020-01-09 15:04:47 +0000 |
commit | d857e114b5e04f5143485a5aea7ad9b283768692 (patch) | |
tree | 2f332c8d574705cb51c98c04e795b1894139c303 | |
parent | 667e1f71b83c48b635b13b64bbff28b95e68265c (diff) | |
download | bcm5719-llvm-d857e114b5e04f5143485a5aea7ad9b283768692.tar.gz bcm5719-llvm-d857e114b5e04f5143485a5aea7ad9b283768692.zip |
[ARM,MVE] Fix valid immediate range for vsliq_n.
In common with most MVE immediate shift instructions, the left shift
takes an immediate in the range [0,n-1], while the right shift takes
one in the range [1,n]. I had absent-mindedly made them both the
latter.
While I'm here, I've added a set of regression tests checking both
ends of the immediate range for a representative sample of the
immediate shifts.
-rw-r--r-- | clang/include/clang/Basic/arm_mve.td | 2 | ||||
-rw-r--r-- | clang/test/Sema/arm-mve-immediates.c | 93 |
2 files changed, 94 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/arm_mve.td b/clang/include/clang/Basic/arm_mve.td index 87091a32507..86a04e33ce7 100644 --- a/clang/include/clang/Basic/arm_mve.td +++ b/clang/include/clang/Basic/arm_mve.td @@ -684,7 +684,7 @@ let params = [s16, s32], pnt = PNT_NType in { defm vqrshrun : VSHRN<UHalfVector, imm_1toHalfN, (? 1,0,1,0)>; } let params = T.Int, pnt = PNT_NType in { - defm vsli : DyadicImmShift<Vector, imm_1toN>; + defm vsli : DyadicImmShift<Vector, imm_0toNm1>; defm vsri : DyadicImmShift<Vector, imm_1toN>; } diff --git a/clang/test/Sema/arm-mve-immediates.c b/clang/test/Sema/arm-mve-immediates.c index 54cdb96efcd..b8106fbb702 100644 --- a/clang/test/Sema/arm-mve-immediates.c +++ b/clang/test/Sema/arm-mve-immediates.c @@ -110,3 +110,96 @@ void test_lane_indices(uint8x16_t v16, uint16x8_t v8, vsetq_lane_u64(23, v2, 1); vsetq_lane_u64(23, v2, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}} } + +void test_immediate_shifts(uint8x16_t vb, uint16x8_t vh, uint32x4_t vw) +{ + vshlq_n(vb, 0); + vshlq_n(vb, 7); + vshlq_n(vh, 0); + vshlq_n(vh, 15); + vshlq_n(vw, 0); + vshlq_n(vw, 31); + + vshlq_n(vb, -1); // expected-error {{argument value -1 is outside the valid range [0, 7]}} + vshlq_n(vb, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}} + vshlq_n(vh, -1); // expected-error {{argument value -1 is outside the valid range [0, 15]}} + vshlq_n(vh, 16); // expected-error {{argument value 16 is outside the valid range [0, 15]}} + vshlq_n(vw, -1); // expected-error {{argument value -1 is outside the valid range [0, 31]}} + vshlq_n(vw, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}} + + vqshlq_n(vb, 0); + vqshlq_n(vb, 7); + vqshlq_n(vh, 0); + vqshlq_n(vh, 15); + vqshlq_n(vw, 0); + vqshlq_n(vw, 31); + + vqshlq_n(vb, -1); // expected-error {{argument value -1 is outside the valid range [0, 7]}} + vqshlq_n(vb, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}} + vqshlq_n(vh, -1); // expected-error {{argument value -1 is outside the valid range [0, 15]}} + vqshlq_n(vh, 16); // expected-error {{argument value 16 is outside the valid range [0, 15]}} + vqshlq_n(vw, -1); // expected-error {{argument value -1 is outside the valid range [0, 31]}} + vqshlq_n(vw, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}} + + vsliq(vb, vb, 0); + vsliq(vb, vb, 7); + vsliq(vh, vh, 0); + vsliq(vh, vh, 15); + vsliq(vw, vw, 0); + vsliq(vw, vw, 31); + + vsliq(vb, vb, -1); // expected-error {{argument value -1 is outside the valid range [0, 7]}} + vsliq(vb, vb, 8); // expected-error {{argument value 8 is outside the valid range [0, 7]}} + vsliq(vh, vh, -1); // expected-error {{argument value -1 is outside the valid range [0, 15]}} + vsliq(vh, vh, 16); // expected-error {{argument value 16 is outside the valid range [0, 15]}} + vsliq(vw, vw, -1); // expected-error {{argument value -1 is outside the valid range [0, 31]}} + vsliq(vw, vw, 32); // expected-error {{argument value 32 is outside the valid range [0, 31]}} + + vshllbq(vb, 1); + vshllbq(vb, 8); + vshllbq(vh, 1); + vshllbq(vh, 16); + + vshllbq(vb, 0); // expected-error {{argument value 0 is outside the valid range [1, 8]}} + vshllbq(vb, 9); // expected-error {{argument value 9 is outside the valid range [1, 8]}} + vshllbq(vh, 0); // expected-error {{argument value 0 is outside the valid range [1, 16]}} + vshllbq(vh, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}} + + vshrq(vb, 1); + vshrq(vb, 8); + vshrq(vh, 1); + vshrq(vh, 16); + vshrq(vw, 1); + vshrq(vw, 32); + + vshrq(vb, 0); // expected-error {{argument value 0 is outside the valid range [1, 8]}} + vshrq(vb, 9); // expected-error {{argument value 9 is outside the valid range [1, 8]}} + vshrq(vh, 0); // expected-error {{argument value 0 is outside the valid range [1, 16]}} + vshrq(vh, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}} + vshrq(vw, 0); // expected-error {{argument value 0 is outside the valid range [1, 32]}} + vshrq(vw, 33); // expected-error {{argument value 33 is outside the valid range [1, 32]}} + + vshrntq(vb, vh, 1); + vshrntq(vb, vh, 8); + vshrntq(vh, vw, 1); + vshrntq(vh, vw, 16); + + vshrntq(vb, vh, 0); // expected-error {{argument value 0 is outside the valid range [1, 8]}} + vshrntq(vb, vh, 9); // expected-error {{argument value 9 is outside the valid range [1, 8]}} + vshrntq(vh, vw, 0); // expected-error {{argument value 0 is outside the valid range [1, 16]}} + vshrntq(vh, vw, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}} + + vsriq(vb, vb, 1); + vsriq(vb, vb, 8); + vsriq(vh, vh, 1); + vsriq(vh, vh, 16); + vsriq(vw, vw, 1); + vsriq(vw, vw, 32); + + vsriq(vb, vb, 0); // expected-error {{argument value 0 is outside the valid range [1, 8]}} + vsriq(vb, vb, 9); // expected-error {{argument value 9 is outside the valid range [1, 8]}} + vsriq(vh, vh, 0); // expected-error {{argument value 0 is outside the valid range [1, 16]}} + vsriq(vh, vh, 17); // expected-error {{argument value 17 is outside the valid range [1, 16]}} + vsriq(vw, vw, 0); // expected-error {{argument value 0 is outside the valid range [1, 32]}} + vsriq(vw, vw, 33); // expected-error {{argument value 33 is outside the valid range [1, 32]}} +} |