[PATCH] D142388: [clang] Add builtin_nondet

Manuel Brito via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 24 07:04:07 PST 2023


ManuelJBrito updated this revision to Diff 491767.
ManuelJBrito added a comment.

Add tests with bool and bool-vector


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142388/new/

https://reviews.llvm.org/D142388

Files:
  clang/test/CodeGen/builtins-nondet.c


Index: clang/test/CodeGen/builtins-nondet.c
===================================================================
--- clang/test/CodeGen/builtins-nondet.c
+++ clang/test/CodeGen/builtins-nondet.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
 
 typedef float float4 __attribute__((ext_vector_type(4)));
+typedef _Bool bool4 __attribute__((ext_vector_type(4)));
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
@@ -29,7 +30,17 @@
   return __builtin_nondet(x);
 } 
 
-float4 clang_nondet_v( float4 x ) {
+_Bool clang_nondet_b( _Bool x) {
+// CHECK-LABEL: entry
+// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[B:%.*]] = zext i1 %x to i8
+// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: [[R:%.*]] = freeze i1 poison
+// CHECK: ret i1 [[R]]
+  return __builtin_nondet(x);
+} 
+
+float4 clang_nondet_fv( float4 x ) {
 // CHECK-LABEL: entry
 // CHECK: [[A:%.*]] = alloca <4 x float>, align 16
 // CHECK: store <4 x float> [[X:%.*]], ptr [[A]], align 16
@@ -38,3 +49,14 @@
   return __builtin_nondet(x);
 } 
 
+bool4 clang_nondet_bv( bool4 x ) {
+// CHECK-LABEL: entry
+// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[V:%.*]] = shufflevector <4 x i1> [[X:%.*]], <4 x i1> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
+// CHECK: [[B:%.*]] = bitcast <8 x i1> [[V]] to i8
+// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: [[R:%.*]] = freeze <4 x i1> poison
+// CHECK: ret <4 x i1> [[R]]
+  return __builtin_nondet(x);
+} 
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142388.491767.patch
Type: text/x-patch
Size: 1516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230124/c6b49913/attachment.bin>


More information about the cfe-commits mailing list