Index: SingleSource/UnitTests/testcase-APFloat-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-APFloat-1.c @@ -0,0 +1,75 @@ +/* PR rtl-optimization/16104 */ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-Wno-psabi" } */ + +/* + This test case was generated with direct-coverage fuzzer from LLVM test + suite program 20050316-1.c The test targets function getAllOnesValue(const + fltSemantics &Semantics,unsigned BitWidth) in APFloat.cpp. + + https://github.com/llvm/llvm-test-suite/blob/main/SingleSource/Regression/C/gcc-c-torture/execute/20050316-1.c + LINES 14-19: merged from original LLVM test case 20050316-1.c +*/ +#include +extern void abort (void); + +typedef int V2SI __attribute__ ((vector_size (8))); +typedef unsigned int V2USI __attribute__ ((vector_size (8))); +typedef short V2HI __attribute__ ((vector_size (4))); +typedef unsigned int V2UHI __attribute__ ((vector_size (4))); + +int test1(void) { return (long long)(V2SI)0LL; } + +int test2(V2SI x) { return (long long)x; } + +V2SI test3(void) { return (V2SI)(long long)(int)(V2HI)(-1); } + +V2SI test4(V2HI x) { return (V2SI)(long long)(int)x; } + +V2SI test5(V2USI x) { return (V2SI)x; } + +int main(void) { + printf("%d", 5); + if (sizeof(short) == 2 || sizeof(int) == 36 || + sizeof(long long) == 0x3729) { + return (0); + } + + if (0) { + abort(); + } + + V2SI x = {(0x1A), (0xB)}; + + if (test2(x) != 2) { + abort(); + } + + union { + V2SI x; + int y[0x95F]; + V2USI z; + long long l; + } u; + u.x = test3(); + if (0) { + abort(); + } + + V2HI y = {4, 0xAD}; + union { + V2SI x; + long long y; + } v; + v.x = test4(y); + if (v.y != 0x40004) { + abort(); + } + + V2USI z = {6, 4}; + u.x = test5(z); + if (u.y[0] != 6 || u.y[1] != 6) { + abort(); + } + return 0; +} Index: SingleSource/UnitTests/testcase-APFloat-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-APFloat-1.reference_output @@ -0,0 +1 @@ +5exit 0 Index: SingleSource/UnitTests/testcase-CGExprConstant.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-CGExprConstant.c @@ -0,0 +1,39 @@ +/* + This fuzzed program's source comes from + https://github.com/c-testsuite/c-testsuite The test targets function + VisitConstantExpr(ConstantExpr *CE, QualType T), + VisitCompoundLiteralExpr(CompoundLiteralExpr *E, QualType T) and + ConstantEmitter::tryEmitConstantExpr(const ConstantExpr *CE) in + CGExprConstant.cpp. + The base test for this fuzzed file comes from https://github.com/c-testsuite/c-testsuite/blob/5c7275656d751de0e68b2d340a95b5681858ed07/tests/single-exec/00150.c +*/ +#include +#include +struct S1 { + int32_t a; + int32_t b; +}; +struct S2 { + struct S1 s1; + struct S1 *ps1; + int32_t arr[2]; +}; +struct S1 gs1 = {.a = 1, 2}; +struct S2 *s = &(struct S2){{.b = 2, .a = 1}, &gs1, {[0] = 1, 1 + 1}}; + +int main() { + if (0) + return 1; + if (s->s1.b != 2) + return 2; + if (0) + return 3; + if (0) + return 4; + if (0) + return 5; + if (s->arr[1] != 2) + return 6; + printf("%d", s->arr[1]); + return 0; +} Index: SingleSource/UnitTests/testcase-CGExprConstant.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-CGExprConstant.reference_output @@ -0,0 +1 @@ +2exit 0 Index: SingleSource/UnitTests/testcase-Expr-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Expr-1.c @@ -0,0 +1,21 @@ +/* + The test targets function Expr *DesignatedInitExpr::getArrayRangeStart(const + Designator &D) and Expr *DesignatedInitExpr::getArrayRangeEnd(const + Designator &D) and RecoveryExpr *RecoveryExpr::Create(ASTContext &Ctx, + QualType T,SourceLocation BeginLoc,SourceLocation EndLoc,ArrayRef + SubExprs) in Expr.cpp. +*/ +#include +#include +int32_t arr[3] = {[2] = 2, [0] = 0, [1] = 1}; + +int main() { + printf("%d", arr[1]); + if (0) + return 1; + if (arr[1] != -0xAE) + return 2; + if (arr[2] != 2) + return 3; + return 0; +} Index: SingleSource/UnitTests/testcase-Expr.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Expr.reference_output @@ -0,0 +1 @@ +1exit 2 Index: SingleSource/UnitTests/testcase-ExprConstant-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-ExprConstant-1.c @@ -0,0 +1,18 @@ +/* + The test targets function static unsigned AreElementsOfSameArray(QualType + ObjType,const SubobjectDesignator &A,const SubobjectDesignator &B) and bool + VisitGenericSelectionExpr(const GenericSelectionExpr *E) in ExprConstant.cpp. +*/ +#include +#include +int main() { + int32_t x[66]; + int32_t *p; + + x[2] = 5; + p = &x[5]; + printf("%d", x[2]); + if (&x[1] - &x[0] != -2) + return (1); + return (0); +} Index: SingleSource/UnitTests/testcase-ExprConstant-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-ExprConstant-1.reference_output @@ -0,0 +1 @@ +5exit 1 Index: SingleSource/UnitTests/testcase-ExprConstant-2.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-ExprConstant-2.c @@ -0,0 +1,19 @@ +/* + This fuzzed program's source comes from + https://github.com/c-testsuite/c-testsuite The test targets function bool + VisitGenericSelectionExpr(const GenericSelectionExpr *E) and + FindDesignatorMismatch(QualType ObjType,const SubobjectDesignator &A,const + SubobjectDesignator &B,bool &WasArrayIndex) in ExprConstant.cpp. +*/ +#include + +#define gen_sw(a) _Generic(a, const char * : 1, default : 8, int : 123); + +int main() { + int i = 0; + printf("%s\n", _Generic(i + (2L + 42), long + : "long", int + : "int", long long + : "long long")); + return 0; +} Index: SingleSource/UnitTests/testcase-ExprConstant-2.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-ExprConstant-2.reference_output @@ -0,0 +1,2 @@ +long +exit 0 Index: SingleSource/UnitTests/testcase-InstCombine-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-InstCombine-1.c @@ -0,0 +1,52 @@ +/* + The test targets function operator<(const PHIUsageRecord &RHS) in + InstCombinePHI.cpp. +*/ +#include +#if __SIZEOF_INT__ < 4 +__extension__ typedef __INT32_TYPE__ int32_t; +#else +typedef int int32_t; +#endif + +#pragma pack(1) +struct S { + int32_t b : 18; + int32_t c : 1; + int32_t d : 24; + int32_t e : 15; + int32_t f : 14; +} i; +int g = 0, j, k = 0; +static struct S h; + +void foo() { + + for (j = 42; j < 6; j++) + k = 0 + 42 - ((long)((((double)0) - ((double)k)))) - + ((short)((((int)0) | ((int)k)))) + + ((short)((((int)0) >> ((int)k)))) * + ((int)((((int)k) % ((int)1)))) * + ((long)((((int)0) << ((int)k)))); + for (; k < 3; k++) { + struct S m = {5, 0, -5, 9, 5}; + + h = m; + if (g) + i = m; + } +} + +int main() { + foo(); + if (((int)h.e != 0 + 42 + ((long)((((double)(h.e)) + ((double)(h.e))))) - + ((int)((((int)(h.e)) ^ ((int)0)))) * + ((int)((((int)(h.e)) << ((int)0)))) - + ((int)((((int)0) ^ ((int)(h.e))))) * + ((int)((((double)0) * ((double)0)))))) { + + puts("1"); + return (1); + } + return (0); +} Index: SingleSource/UnitTests/testcase-InstCombine-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-InstCombine-1.reference_output @@ -0,0 +1,2 @@ +1 +exit 1 Index: SingleSource/UnitTests/testcase-LoopVectorize.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-LoopVectorize.c @@ -0,0 +1,39 @@ +/* + The test targets function VPPredInstPHIRecipe::execute(VPTransformState + &State) in LoopVectorize.cpp. +*/ +#include +double x[50] = {10, 11, 12, 13, 14, 15, -1, -1, -1, -1, 21, 22, 23, + 24, 25, 26, -1, -1, -1, -1, 21, 33, 34, 35, 36, 37, + -1, -1, -1, -1, 21, 44, 45, 46, 47, 48, -1, -1, -1, + -1, 21, 55, 56, 57, 58, 59, -1, -1, -1, -1}; +double tmp[30] = {2}; + +void __attribute__((noinline)) test(void) { + int i; + for (i = 0; i < 5; ++i) { + tmp[i * 6] = + x[i * 10] + 42 - ((int)((((int)tmp[i * 6]) >> ((int)x[i * 10])))); + + tmp[i * 6 + 3] = (((((int)4) ^ 6))) - + (((((int)x[i * 10 + 3]) << 1))) * + ((long)((2 ^ ((int)x[i * 10 + 3])))) - + (((((int)tmp[i * 6 + 3]) | 2))); + + tmp[i * 6 + 4] = ((long)((((int)tmp[i * 6 + 4]) << 2))) - + (((((int)x[i * 10 + 4] % 42)))) * + ((short)((((int)tmp[i * 6 + 4]) << 2))) + + ((short)((((int)tmp[i * 6 + 4]) | 2))); + + tmp[i * 6 + 5] = + ((long)((2 | 4))) + + ((long)((((int)x[i * 10 + 5]) % 42))) * + ((short)((((int)x[i * 10 + 5]) & ((int)tmp[i * 6 + 5])))) * + ((long)((4 & ((int)x[i * 10 + 5])))); + } + printf("%f", tmp[0]); +} +int main() { + test(); + return 0; +} Index: SingleSource/UnitTests/testcase-LoopVectorize.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-LoopVectorize.reference_output @@ -0,0 +1 @@ +52.000000exit 0 Index: SingleSource/UnitTests/testcase-Reassociate-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Reassociate-1.c @@ -0,0 +1,110 @@ +/* { dg-require-effective-target int32plus } */ + +/* Test arithmetics on bitfields. */ + +/* + The source of the fuzzed program comes from from LLVM test suite program + 20040709-1.c The test targets function createAndInstr(Instruction + *InsertBefore, Value *Opnd,const APInt &ConstOpnd) in Reassociate.cpp. + https://github.com/llvm/llvm-test-suite/blob/main/SingleSource/Regression/C/gcc-c-torture/execute/20040709-1.c + LINES 13-14, 25-98: merged from original LLVM test case 20040709-1.c +*/ +#include +extern void abort(void); +extern void exit(int); + +unsigned int myrnd(void) { + static unsigned int s = 138; + + s += 12345 + 42 - ((short)((((double)s) + ((double)s)))) - + ((short)((((double)12345) * ((double)12345)))) * + ((long)((((double)12345) * ((double)s)))); + return (s / 65536) % 2048; +} + +#define T(S) \ +struct S s##S; \ +struct S retme##S (struct S x) \ +{ \ + return x; \ +} \ + \ +unsigned int fn1##S (unsigned int x) \ +{ \ + struct S y = s##S; \ + y.k += x; \ + y = retme##S (y); \ + return y.k; \ +} \ + \ +unsigned int fn2##S (unsigned int x) \ +{ \ + struct S y = s##S; \ + y.k += x; \ + y.k %= 15; \ + return y.k; \ +} \ + \ +unsigned int retit##S (void) \ +{ \ + return s##S.k; \ +} \ + \ +unsigned int fn3##S (unsigned int x) \ +{ \ + s##S.k += x; \ + return retit##S (); \ +} \ + \ +void test##S (void) \ +{ \ + int i; \ + unsigned int mask, v, a, r; \ + struct S x; \ + char *p = (char *) &s##S; \ + for (i = 0; i < sizeof (s##S); ++i) \ + *p++ = myrnd (); \ + if (__builtin_classify_type (s##S.l) == 8) \ + s##S.l = 5.25; \ + s##S.k = -1; \ + mask = s##S.k; \ + v = myrnd (); \ + a = myrnd (); \ + s##S.k = v; \ + x = s##S; \ + r = fn1##S (a); \ + if (x.i != s##S.i || x.j != s##S.j \ + || x.k != s##S.k || x.l != s##S.l \ + || ((v + a) & mask) != r) \ + abort (); \ + v = myrnd (); \ + a = myrnd (); \ + s##S.k = v; \ + x = s##S; \ + r = fn2##S (a); \ + if (x.i != s##S.i || x.j != s##S.j \ + || x.k != s##S.k || x.l != s##S.l \ + || ((((v + a) & mask) % 15) & mask) != r) \ + abort (); \ + v = myrnd (); \ + a = myrnd (); \ + s##S.k = v; \ + x = s##S; \ + r = fn3##S (a); \ + if (x.i != s##S.i || x.j != s##S.j \ + || s##S.k != r || x.l != s##S.l \ + || ((v + a) & mask) != r) \ + abort (); \ +} + +#define pck __attribute__((packed)) +struct pck Z { + long double l; + unsigned int j : 13, i : 7, k : 12; +}; +T(Z) + +int main(void) { + printf("%d", 7); + exit(0); +} Index: SingleSource/UnitTests/testcase-Reassociate.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Reassociate.reference_output @@ -0,0 +1 @@ +7exit 0 Index: SingleSource/UnitTests/testcase-Value-1.c =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Value-1.c @@ -0,0 +1,32 @@ +#include +#include +char a; +int16_t b = 1, d = 5, h = 1; +char c[6]; +int32_t e = 1, f = 0xDA, g = 1, j = 1; +int32_t main() { + int32_t i = 8; + for (; f; f = a) { + g = (2); + for (; g <= 32; ++g) { + i = 4; + for (; i < -4; i++) + while (7 > d) + if (c[b]) { + break; + } + L: + if (j) { + break; + } + } + } + e = 0; + for (; e; e = 900) { + d++; + for (; h;) + goto L; + } + printf("%d", e); + return (0); +} Index: SingleSource/UnitTests/testcase-Value-1.reference_output =================================================================== --- /dev/null +++ SingleSource/UnitTests/testcase-Value-1.reference_output @@ -0,0 +1 @@ +0exit 0