xref: /llvm-project/llvm/test/CodeGen/SPIRV/transcoding/NoSignedUnsignedWrap.ll (revision d06ba376833553f38b5cbc606e479ed7936e5f5b)
1;; Source
2;; int square(unsigned short a) {
3;;   return a * a;
4;; }
5;; Command
6;; clang -cc1 -triple spir -emit-llvm -O2 -o NoSignedUnsignedWrap.ll test.cl
7;;
8;; Positive tests:
9;;
10; RUN: llc -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_KHR_no_integer_wrap_decoration %s -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-NEGATIVE
11;;
12;; Negative tests:
13;;
14;; Check that backend is able to skip nsw/nuw attributes if extension is
15;; disabled implicitly or explicitly and if max SPIR-V version is lower then 1.4
16
17; CHECK-SPIRV-DAG: OpDecorate %[[#]] NoSignedWrap
18; CHECK-SPIRV-DAG: OpDecorate %[[#]] NoUnsignedWrap
19;
20; CHECK-SPIRV-NEGATIVE-NOT: OpExtension "SPV_KHR_no_integer_wrap_decoration"
21; CHECK-SPIRV-NEGATIVE-NOT: OpDecorate %[[#]] NoSignedWrap
22; CHECK-SPIRV-NEGATIVE-NOT: OpDecorate %[[#]] NoUnsignedWrap
23
24define spir_func i32 @square(i16 zeroext %a) local_unnamed_addr {
25entry:
26  %conv = zext i16 %a to i32
27  %mul = mul nuw nsw i32 %conv, %conv
28  ret i32 %mul
29}
30