[llvm] 541041d - AMDGPU: Fix faulty divergence analysis tests

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 6 22:14:24 PST 2022


Author: Matt Arsenault
Date: 2022-11-06T22:14:12-08:00
New Revision: 541041d1eaa83346532d16785ec0ff8d795be8ba

URL: https://github.com/llvm/llvm-project/commit/541041d1eaa83346532d16785ec0ff8d795be8ba
DIFF: https://github.com/llvm/llvm-project/commit/541041d1eaa83346532d16785ec0ff8d795be8ba.diff

LOG: AMDGPU: Fix faulty divergence analysis tests

These were supposed to be checking that atomics were treated
as divergence sources. However, they were using function arguments
which are always treated as divergent, so they could have
been found divergent for the wrong reason.

Added: 
    

Modified: 
    llvm/test/Analysis/DivergenceAnalysis/AMDGPU/atomics.ll
    llvm/test/Analysis/LegacyDivergenceAnalysis/AMDGPU/atomics.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/DivergenceAnalysis/AMDGPU/atomics.ll b/llvm/test/Analysis/DivergenceAnalysis/AMDGPU/atomics.ll
index dec529a23107..12d7fba69f48 100644
--- a/llvm/test/Analysis/DivergenceAnalysis/AMDGPU/atomics.ll
+++ b/llvm/test/Analysis/DivergenceAnalysis/AMDGPU/atomics.ll
@@ -1,15 +1,18 @@
 ; RUN: opt -mtriple amdgcn-- -passes='print<divergence>' -disable-output %s 2>&1 | FileCheck %s
 
 ; CHECK: DIVERGENT: %orig = atomicrmw xchg i32* %ptr, i32 %val seq_cst
-define i32 @test1(i32* %ptr, i32 %val) #0 {
+define amdgpu_kernel void @test1(i32* %ptr, i32 %val) #0 {
   %orig = atomicrmw xchg i32* %ptr, i32 %val seq_cst
-  ret i32 %orig
+  store i32 %orig, i32* %ptr
+  ret void
 }
 
 ; CHECK: DIVERGENT: %orig = cmpxchg i32* %ptr, i32 %cmp, i32 %new seq_cst seq_cst
-define {i32, i1} @test2(i32* %ptr, i32 %cmp, i32 %new) {
+define amdgpu_kernel void @test2(i32* %ptr, i32 %cmp, i32 %new) {
   %orig = cmpxchg i32* %ptr, i32 %cmp, i32 %new seq_cst seq_cst
-  ret {i32, i1} %orig
+  %val = extractvalue { i32, i1 } %orig, 0
+  store i32 %val, i32* %ptr
+  ret void
 }
 
 ; CHECK: DIVERGENT: %ret = call i32 @llvm.amdgcn.atomic.inc.i32.p1i32(i32 addrspace(1)* %ptr, i32 %val, i32 0, i32 0, i1 false)

diff  --git a/llvm/test/Analysis/LegacyDivergenceAnalysis/AMDGPU/atomics.ll b/llvm/test/Analysis/LegacyDivergenceAnalysis/AMDGPU/atomics.ll
index 932ac8ede1f5..e6f2385ba130 100644
--- a/llvm/test/Analysis/LegacyDivergenceAnalysis/AMDGPU/atomics.ll
+++ b/llvm/test/Analysis/LegacyDivergenceAnalysis/AMDGPU/atomics.ll
@@ -1,15 +1,18 @@
 ; RUN: opt -mtriple=amdgcn-- -amdgpu-use-legacy-divergence-analysis -passes='print<divergence>' 2>&1 -disable-output %s | FileCheck %s
 
 ; CHECK: DIVERGENT: %orig = atomicrmw xchg i32* %ptr, i32 %val seq_cst
-define i32 @test1(i32* %ptr, i32 %val) #0 {
+define amdgpu_kernel void @test1(i32* %ptr, i32 %val) #0 {
   %orig = atomicrmw xchg i32* %ptr, i32 %val seq_cst
-  ret i32 %orig
+  store i32 %orig, i32* %ptr
+  ret void
 }
 
 ; CHECK: DIVERGENT: %orig = cmpxchg i32* %ptr, i32 %cmp, i32 %new seq_cst seq_cst
-define {i32, i1} @test2(i32* %ptr, i32 %cmp, i32 %new) {
+define amdgpu_kernel void @test2(i32* %ptr, i32 %cmp, i32 %new) {
   %orig = cmpxchg i32* %ptr, i32 %cmp, i32 %new seq_cst seq_cst
-  ret {i32, i1} %orig
+  %val = extractvalue { i32, i1 } %orig, 0
+  store i32 %val, i32* %ptr
+  ret void
 }
 
 ; CHECK: DIVERGENT: %ret = call i32 @llvm.amdgcn.atomic.inc.i32.p1i32(i32 addrspace(1)* %ptr, i32 %val, i32 0, i32 0, i1 false)


        


More information about the llvm-commits mailing list