gep-addrspace.ll 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. ; RUN: opt < %s -instcombine -S | FileCheck %s
  2. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
  3. target triple = "x86_64-pc-win32"
  4. %myStruct = type { float, [3 x float], [4 x float], i32 }
  5. ; make sure that we are not crashing when creating an illegal type
  6. define void @func(%myStruct addrspace(1)* nocapture %p) nounwind {
  7. ST:
  8. %A = getelementptr inbounds %myStruct, %myStruct addrspace(1)* %p, i64 0
  9. %B = addrspacecast %myStruct addrspace(1)* %A to %myStruct*
  10. %C = getelementptr inbounds %myStruct, %myStruct* %B, i32 0, i32 1
  11. %D = getelementptr inbounds [3 x float], [3 x float]* %C, i32 0, i32 2
  12. %E = load float, float* %D, align 4
  13. %F = fsub float %E, undef
  14. ret void
  15. }
  16. @array = internal addrspace(3) global [256 x float] zeroinitializer, align 4
  17. @scalar = internal addrspace(3) global float 0.000000e+00, align 4
  18. define void @keep_necessary_addrspacecast(i64 %i, float** %out0, float** %out1) {
  19. entry:
  20. ; CHECK-LABEL: @keep_necessary_addrspacecast
  21. %0 = getelementptr [256 x float], [256 x float]* addrspacecast ([256 x float] addrspace(3)* @array to [256 x float]*), i64 0, i64 %i
  22. ; CHECK: addrspacecast float addrspace(3)* %{{[0-9]+}} to float*
  23. %1 = getelementptr [0 x float], [0 x float]* addrspacecast (float addrspace(3)* @scalar to [0 x float]*), i64 0, i64 %i
  24. ; CHECK: addrspacecast float addrspace(3)* %{{[0-9]+}} to float*
  25. store float* %0, float** %out0, align 4
  26. store float* %1, float** %out1, align 4
  27. ret void
  28. }