Value alignedPtr = allocatedPtr;
if (alignment) {
- auto intPtrType = getIntPtrType(memRefType.getMemorySpaceAsInt());
// Compute the aligned type pointer.
Value allocatedInt =
- rewriter.create<LLVM::PtrToIntOp>(loc, intPtrType, allocatedPtr);
+ rewriter.create<LLVM::PtrToIntOp>(loc, getIndexType(), allocatedPtr);
Value alignmentInt =
createAligned(rewriter, loc, allocatedInt, alignment);
alignedPtr =
-// RUN: mlir-opt -convert-std-to-llvm %s | FileCheck %s
+// RUN: mlir-opt -convert-std-to-llvm -split-input-file %s | FileCheck %s
// RUN: mlir-opt -convert-std-to-llvm='use-bare-ptr-memref-call-conv=1' -split-input-file %s | FileCheck %s --check-prefix=BAREPTR
// BAREPTR-LABEL: func @check_noalias
// BAREPTR-NEXT: return %{{.*}} : memref<*xi8>
return %res : memref<*xi8>
}
+
+// -----
+
+// Check that consistent types are emitted in address arithemic in presence of
+// a data layout specification.
+module attributes { dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<index, 32>> } {
+ func @address() {
+ %c1 = constant 1 : index
+ %0 = memref.alloc(%c1) : memref<? x vector<2xf32>>
+ // CHECK: %[[CST:.*]] = llvm.mlir.constant(1 : index) : i32
+ // CHECK: llvm.mlir.null
+ // CHECK: llvm.getelementptr %{{.*}}[[CST]]
+ // CHECK: llvm.ptrtoint %{{.*}} : !llvm.ptr<{{.*}}> to i32
+ // CHECK: llvm.ptrtoint %{{.*}} : !llvm.ptr<{{.*}}> to i32
+ // CHECK: llvm.add %{{.*}} : i32
+ // CHECK: llvm.call @malloc(%{{.*}}) : (i32) -> !llvm.ptr
+ // CHECK: llvm.ptrtoint %{{.*}} : !llvm.ptr<{{.*}}> to i32
+ // CHECK: llvm.sub {{.*}} : i32
+ // CHECK: llvm.add {{.*}} : i32
+ // CHECK: llvm.urem {{.*}} : i32
+ // CHECK: llvm.sub {{.*}} : i32
+ // CHECK: llvm.inttoptr %{{.*}} : i32 to !llvm.ptr
+ return
+ }
+}