[llvm] r278589 - AMDGPU: Fix missing test for addressing mode with odd offsets

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 12 18:43:51 PDT 2016


Author: arsenm
Date: Fri Aug 12 20:43:51 2016
New Revision: 278589

URL: http://llvm.org/viewvc/llvm-project?rev=278589&view=rev
Log:
AMDGPU: Fix missing test for addressing mode with odd offsets

Add test if the constant offset looks unaligned.

Modified:
    llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
    llvm/trunk/test/CodeGen/AMDGPU/cgp-addressing-modes.ll

Modified: llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp?rev=278589&r1=278588&r2=278589&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp Fri Aug 12 20:43:51 2016
@@ -361,6 +361,7 @@ bool SITargetLowering::isLegalAddressing
   case AMDGPUAS::CONSTANT_ADDRESS: {
     // If the offset isn't a multiple of 4, it probably isn't going to be
     // correctly aligned.
+    // FIXME: Can we get the real alignment here?
     if (AM.BaseOffs % 4 != 0)
       return isLegalMUBUFAddressingMode(AM);
 

Modified: llvm/trunk/test/CodeGen/AMDGPU/cgp-addressing-modes.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/cgp-addressing-modes.ll?rev=278589&r1=278588&r2=278589&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/cgp-addressing-modes.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/cgp-addressing-modes.ll Fri Aug 12 20:43:51 2016
@@ -220,11 +220,6 @@ done:
   ret void
 }
 
-attributes #0 = { nounwind readnone }
-attributes #1 = { nounwind }
-
-
-
 ; OPT-LABEL: @test_sink_constant_small_offset_i32
 ; OPT-NOT:  getelementptr i32, i32 addrspace(2)*
 ; OPT: br i1
@@ -475,6 +470,37 @@ bb34:
   unreachable
 }
 
+; Address offset is not a multiple of 4. This is a valid mubuf offset,
+; but not smrd.
+
+; OPT-LABEL: @test_sink_constant_small_max_mubuf_offset_load_i32_align_1(
+; OPT: br i1 %tmp0,
+; OPT: if:
+; OPT: %sunkaddr = ptrtoint i8 addrspace(2)* %in to i64
+; OPT: %sunkaddr1 = add i64 %sunkaddr, 4095
+define void @test_sink_constant_small_max_mubuf_offset_load_i32_align_1(i32 addrspace(1)* %out, i8 addrspace(2)* %in) {
+entry:
+  %out.gep = getelementptr i32, i32 addrspace(1)* %out, i32 1024
+  %in.gep = getelementptr i8, i8 addrspace(2)* %in, i64 4095
+  %tid = call i32 @llvm.amdgcn.mbcnt.lo(i32 -1, i32 0) #0
+  %tmp0 = icmp eq i32 %tid, 0
+  br i1 %tmp0, label %endif, label %if
+
+if:
+  %bitcast = bitcast i8 addrspace(2)* %in.gep to i32 addrspace(2)*
+  %tmp1 = load i32, i32 addrspace(2)* %bitcast, align 1
+  br label %endif
+
+endif:
+  %x = phi i32 [ %tmp1, %if ], [ 0, %entry ]
+  store i32 %x, i32 addrspace(1)* %out.gep
+  br label %done
+
+done:
+  ret void
+}
+
 declare i32 @llvm.amdgcn.mbcnt.lo(i32, i32) #0
 
 attributes #0 = { nounwind readnone }
+attributes #1 = { nounwind }




More information about the llvm-commits mailing list