[PATCH] D18473: AMDGPU: Add test for generic builtin behavior

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 25 06:25:34 PDT 2016


arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: cfe-commits.

This is the same as the default implementation, but
add a comment and make sure the behavior is tested.

http://reviews.llvm.org/D18473

Files:
  lib/Basic/Targets.cpp
  test/CodeGenOpenCL/builtins-generic-amdgcn.cl

Index: test/CodeGenOpenCL/builtins-generic-amdgcn.cl
===================================================================
--- /dev/null
+++ test/CodeGenOpenCL/builtins-generic-amdgcn.cl
@@ -0,0 +1,16 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @test_builtin_clz(
+// CHECK: tail call i32 @llvm.ctlz.i32(i32 %a, i1 true)
+void test_builtin_clz(global int* out, int a)
+{
+  *out = __builtin_clz(a);
+}
+
+// CHECK-LABEL: @test_builtin_clzl(
+// CHECK: tail call i64 @llvm.ctlz.i64(i64 %a, i1 true)
+void test_builtin_clzl(global long* out, long a)
+{
+  *out = __builtin_clzl(a);
+}
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1851,6 +1851,11 @@
                         clang::AMDGPU::LastTSBuiltin - Builtin::FirstTSBuiltin);
   }
 
+  bool isCLZForZeroUndef() const override {
+    // It is -1 instead of expected for intrinsic.
+    return true;
+  }
+
   void getTargetDefines(const LangOptions &Opts,
                         MacroBuilder &Builder) const override {
     if (getTriple().getArch() == llvm::Triple::amdgcn)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18473.51632.patch
Type: text/x-patch
Size: 1240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160325/257eec19/attachment.bin>


More information about the cfe-commits mailing list