swar-c99-6.8.6.1-goto_stmt.c 1.29 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.6.1-goto_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"

#define LEN 3

const su4x8b a[LEN] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
su4x8b b[LEN] = {{10,20,30,40},{50,60,70,80},{90,100,110,120}};
su4x8b z[LEN] = {{0},{1},{10}};

int foo(void)
{
  #pragma swar saturate

  z[0] = a[0] + b[1];

  #pragma swar reduce
  
  z[1] = a[0] + b[2];
  
label:                  // label does not create standalone blocks
  z[2] = a[1] + b[0];

  #pragma swar normalize
  z[0] = a[2] + b[1];
  
  goto label;

  return 0;
}

int main(void)
{
  foo();

  return 0;
}