swar-c99-6.8.5.2-do_stmt.c 1.61 KB
/* -----------------------------------------------------------------------------
 *  Copyright (C) 2018-2020 daiteq s.r.o.                http://www.daiteq.com
 *
 *  This program is distributed WITHOUT ANY WARRANTY; without even
 *  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 *  PURPOSE.
 *
 * -----------------------------------------------------------------------------
 *  Filename    : swar-c99-6.8.5.2-do_stmt.c
 *  Authors     : Roman Bartosinski
 *  Description : simple test of clang/LLVM compiler with SWAR extension
 *  Release     :
 *  Version     :
 *  Date        :
 * -----------------------------------------------------------------------------
 */

//A: --has-swar
//C: -daiteq-swar-enable

#define SWAR_USE_UNSIGNED_TYPES
#define SWAR_USE_SIGNED_TYPES
#include "swar-c99.h"

// iteration statements: while, do-while, for
#define ARRAYSIZE 20
su10x3b v3u[ARRAYSIZE] = {
  {0,1,2,3,4,5,6,7,0,1},
  {0,1,2,3,4,0,1,2,3,4},
  {1,1,1,4,4,4,4,7,7,7},
  {7,6,5,4,3,2,1,0,7,6},
  {0,0,0,0,0,0,0,0,0,0},
  {1,1,1,1,1,1,1,1,1,1},
  {2,2,2,2,2,2,2,2,2,2},
  {3,3,3,3,3,3,3,3,3,3},
  {4,4,4,4,4,4,4,4,4,4},
  {5,5,5,5,5,5,5,5,5,5},
  {6,6,6,6,6,6,6,6,6,6},
  {7,7,7,7,7,7,7,7,7,7},
  {0,0,0,0,0,0,0,0,0,0},
  {1,1,1,1,1,1,1,1,1,1},
  {2,2,2,2,2,2,2,2,2,2},
  {3,3,3,3,3,3,3,3,3,3},
  {4,4,4,4,4,4,4,4,4,4},
  {5,5,5,5,5,5,5,5,5,5},
  {6,6,6,6,6,6,6,6,6,6},
  {7,7,7,7,7,7,7,7,7,7},
};

su10x3b accum10x3u = {0};
ss32x1b var32x1s;


int foo(void)
{
  int i = 0;
  while(i<ARRAYSIZE) {
    accum10x3u += v3u[i];
    i++;
  }
  
  int rc = *((int *)&accum10x3u);

  return rc;
}

int main(void)
{
  foo();

  return 0;
}