[llvm] r342390 - Fix vectorization of canonicalize

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 17 06:24:30 PDT 2018


Author: arsenm
Date: Mon Sep 17 06:24:30 2018
New Revision: 342390

URL: http://llvm.org/viewvc/llvm-project?rev=342390&view=rev
Log:
Fix vectorization of canonicalize

Modified:
    llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h
    llvm/trunk/lib/Analysis/VectorUtils.cpp
    llvm/trunk/test/Transforms/SLPVectorizer/AMDGPU/packed-math.ll

Modified: llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h?rev=342390&r1=342389&r2=342390&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h (original)
+++ llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h Mon Sep 17 06:24:30 2018
@@ -1036,6 +1036,9 @@ public:
     case Intrinsic::fabs:
       ISDs.push_back(ISD::FABS);
       break;
+    case Intrinsic::canonicalize:
+      ISDs.push_back(ISD::FCANONICALIZE);
+      break;
     case Intrinsic::minnum:
       ISDs.push_back(ISD::FMINNUM);
       if (FMF.noNaNs())

Modified: llvm/trunk/lib/Analysis/VectorUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/VectorUtils.cpp?rev=342390&r1=342389&r2=342390&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/VectorUtils.cpp (original)
+++ llvm/trunk/lib/Analysis/VectorUtils.cpp Mon Sep 17 06:24:30 2018
@@ -70,6 +70,7 @@ bool llvm::isTriviallyVectorizable(Intri
   case Intrinsic::ctlz:
   case Intrinsic::cttz:
   case Intrinsic::powi:
+  case Intrinsic::canonicalize:
     return true;
   default:
     return false;

Modified: llvm/trunk/test/Transforms/SLPVectorizer/AMDGPU/packed-math.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SLPVectorizer/AMDGPU/packed-math.ll?rev=342390&r1=342389&r2=342390&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SLPVectorizer/AMDGPU/packed-math.ll (original)
+++ llvm/trunk/test/Transforms/SLPVectorizer/AMDGPU/packed-math.ll Mon Sep 17 06:24:30 2018
@@ -179,8 +179,25 @@ define amdgpu_kernel void @test1_fabs_sc
   ret void
 }
 
+; GCN-LABEL: @canonicalize_v2f16
+; GFX9: load <2 x half>
+; GFX9: call <2 x half> @llvm.canonicalize.v2f16(
+; GFX9: store <2 x half>
+define amdgpu_kernel void @canonicalize_v2f16(half addrspace(3)* %a, half addrspace(3)* %c) {
+  %i0 = load half, half addrspace(3)* %a, align 2
+  %canonicalize0 = call half @llvm.canonicalize.f16(half %i0)
+  %arrayidx3 = getelementptr inbounds half, half addrspace(3)* %a, i64 1
+  %i3 = load half, half addrspace(3)* %arrayidx3, align 2
+  %canonicalize1 = call half @llvm.canonicalize.f16(half %i3)
+  store half %canonicalize0, half addrspace(3)* %c, align 2
+  %arrayidx5 = getelementptr inbounds half, half addrspace(3)* %c, i64 1
+  store half %canonicalize1, half addrspace(3)* %arrayidx5, align 2
+  ret void
+}
+
 declare half @llvm.fabs.f16(half) #1
 declare half @llvm.fma.f16(half, half, half) #1
+declare half @llvm.canonicalize.f16(half) #1
 
 attributes #0 = { nounwind }
 attributes #1 = { nounwind readnone }




More information about the llvm-commits mailing list