Skip to content

Commit 29202f4

Browse files
committed
Fix testcases
1 parent d996020 commit 29202f4

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,9 +3817,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
38173817
case X86::BI__builtin_ia32_psignd256:
38183818
return interp__builtin_elementwise_int_binop(
38193819
S, OpPC, Call, [](const APSInt &AElem, const APSInt &BElem) -> APInt {
3820-
return BElem.isNegative() ? static_cast<const APInt &>(-AElem)
3821-
: BElem.isZero() ? APInt(AElem.getBitWidth(), 0)
3822-
: static_cast<const APInt &>(AElem);
3820+
return BElem[BElem.getBitWidth() - 1]
3821+
? static_cast<const APInt &>(-AElem)
3822+
: BElem.isZero() ? APInt(AElem.getBitWidth(), 0)
3823+
: static_cast<const APInt &>(AElem);
38233824
});
38243825

38253826
case clang::X86::BI__builtin_ia32_pavgb128:

clang/lib/AST/ExprConstant.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12318,12 +12318,12 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) {
1231812318
case X86::BI__builtin_ia32_psignw256:
1231912319
case X86::BI__builtin_ia32_psignd128:
1232012320
case X86::BI__builtin_ia32_psignd256:
12321-
return EvaluateBinOpExpr(
12322-
[](const APSInt &AElem, const APSInt &BElem) -> APInt {
12323-
return BElem.isNegative() ? static_cast<const APInt &>(-AElem)
12324-
: BElem.isZero() ? APInt(AElem.getBitWidth(), 0)
12325-
: static_cast<const APInt &>(AElem);
12326-
});
12321+
return EvaluateBinOpExpr([](const APSInt &AElem,
12322+
const APSInt &BElem) -> APInt {
12323+
return BElem[BElem.getBitWidth() - 1] ? static_cast<const APInt &>(-AElem)
12324+
: BElem.isZero() ? APInt(AElem.getBitWidth(), 0)
12325+
: static_cast<const APInt &>(AElem);
12326+
});
1232712327

1232812328
case X86::BI__builtin_ia32_blendvpd:
1232912329
case X86::BI__builtin_ia32_blendvpd256:

clang/test/CodeGen/X86/avx2-builtins.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,23 +1162,23 @@ __m256i test_mm256_sign_epi8(__m256i a, __m256i b) {
11621162
return _mm256_sign_epi8(a, b);
11631163
}
11641164
TEST_CONSTEXPR(match_v32qi(_mm256_sign_epi8(
1165-
(__m256i)(__v32qi){'B','r','i','g','h','t','n','e','o','n','f','o','x','j','u','m','p','s','o','v','e','r','p','r','o','g','r','a','m','m','e','r'},
1166-
(__m256i)(__v32qi){0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'t','h','i','s'}),
1167-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'m','m','e','r'));
1165+
(__m256i)(__v32qs){0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
1166+
(__m256i)(__v32qs){0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1}),
1167+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1));
11681168

11691169
__m256i test_mm256_sign_epi16(__m256i a, __m256i b) {
11701170
// CHECK-LABEL: test_mm256_sign_epi16
11711171
// CHECK: call <16 x i16> @llvm.x86.avx2.psign.w(<16 x i16> %{{.*}}, <16 x i16> %{{.*}})
11721172
return _mm256_sign_epi16(a, b);
11731173
}
1174-
TEST_CONSTEXPR(match_v16hi(_mm256_sign_epi16((__m256i)(__v16hi){0x77,0x77,0xbe,0xbe, -0x9,-0x9,-0x8,-0x8, 0,0,0,0, 0,0,0,0}, (__m256i)(__v16hi){-1,-256,1,256, -512,-1028,512,1028, -2048,-4096,'h','i', 'b','y','e','!'}), -0x77,-0x77,0xbe,0xbe, 0x9,0x9,-0x8,-0x8, 0,0,0,0, 0,0,0,0));
1174+
TEST_CONSTEXPR(match_v16hi(_mm256_sign_epi16((__m256i)(__v16hi){0x77,0x77,0xbe,0xbe, -0x9,-0x9,-0x8,-0x8, 0,0,0,0, 0,0,0,0}, (__m256i)(__v16hi){-1,-256,1,256, -512,-1028,512,1028, -2048,-4096,0,0, 0,0,0,0}), -0x77,-0x77,0xbe,0xbe, 0x9,0x9,-0x8,-0x8, 0,0,0,0, 0,0,0,0));
11751175

11761176
__m256i test_mm256_sign_epi32(__m256i a, __m256i b) {
11771177
// CHECK-LABEL: test_mm256_sign_epi32
11781178
// CHECK: call <8 x i32> @llvm.x86.avx2.psign.d(<8 x i32> %{{.*}}, <8 x i32> %{{.*}})
11791179
return _mm256_sign_epi32(a, b);
11801180
}
1181-
TEST_CONSTEXPR(match_v8si(_mm256_sign_epi32((__m256i)(__v8si){0xbeef,0xfeed,0xbead,0xdeed,'o','o','p','s'}, (__m256i)(__v8si){0,0,0,0,-1,-1,-1,-1}), 0,0,0,0, -'o',-'o',-'p',-'s'));
1181+
TEST_CONSTEXPR(match_v8si(_mm256_sign_epi32((__m256i)(__v8si){0xbeef,0xfeed,0xbead,0xdeed, -1,2,-3,4}, (__m256i)(__v8si){0,0,0,0,-1,-1,-1,-1}), 0,0,0,0, 1,-2,3,-4));
11821182

11831183
__m256i test_mm256_slli_epi16(__m256i a) {
11841184
// CHECK-LABEL: test_mm256_slli_epi16

clang/test/CodeGen/X86/ssse3-builtins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ __m128i test_mm_sign_epi8(__m128i a, __m128i b) {
125125
// CHECK: call <16 x i8> @llvm.x86.ssse3.psign.b.128(<16 x i8> %{{.*}}, <16 x i8> %{{.*}})
126126
return _mm_sign_epi8(a, b);
127127
}
128-
TEST_CONSTEXPR(match_v16qi(_mm_sign_epi8((__m128i)(__v16qi){'g','r','i','n','d','i','n','g', 'l','e','e','t','c','o','d','e'}, (__m128i)(__v16qi){0,1,0,1, 1,1,0,0, 0,0,1,1, 1,0,1,0}), 0,'r',0,'n', 'd','i',0,0, 0,0,'e','t', 'c',0,'d',0));
128+
TEST_CONSTEXPR(match_v16qi(_mm_sign_epi8((__m128i)(__v16qs){11,0,13,14, 0,16,17,18, 19,20,21,22, 23,24,25,26}, (__m128i)(__v16qs){0,1,0,1, -1,1,0,0, 0,0,1,1, -1,0,-1,0}), 0,0,0,14, 0,16,0,0, 0,0,21,22, -23,0,-25,0));
129129

130130
__m128i test_mm_sign_epi16(__m128i a, __m128i b) {
131131
// CHECK-LABEL: test_mm_sign_epi16

0 commit comments

Comments
 (0)