diff options
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 16 | ||||
-rw-r--r-- | llvm/test/CodeGen/AArch64/lower-ptrmask-arm64_32.ll | 12 |
2 files changed, 25 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index c7e0c62..72678c1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -7844,9 +7844,19 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, SDValue Ptr = getValue(I.getOperand(0)); SDValue Mask = getValue(I.getOperand(1)); - EVT PtrVT = Ptr.getValueType(); - assert(PtrVT == Mask.getValueType() && - "Pointers with different index type are not supported by SDAG"); + // On arm64_32, pointers are 32 bits when stored in memory, but + // zero-extended to 64 bits when in registers. Thus the mask is 32 bits to + // match the index type, but the pointer is 64 bits, so the the mask must be + // zero-extended up to 64 bits to match the pointer. + EVT PtrVT = + TLI.getValueType(DAG.getDataLayout(), I.getOperand(0)->getType()); + EVT MemVT = + TLI.getMemValueType(DAG.getDataLayout(), I.getOperand(0)->getType()); + assert(PtrVT == Ptr.getValueType()); + assert(MemVT == Mask.getValueType()); + if (MemVT != PtrVT) + Mask = DAG.getPtrExtOrTrunc(Mask, sdl, PtrVT); + setValue(&I, DAG.getNode(ISD::AND, sdl, PtrVT, Ptr, Mask)); return; } diff --git a/llvm/test/CodeGen/AArch64/lower-ptrmask-arm64_32.ll b/llvm/test/CodeGen/AArch64/lower-ptrmask-arm64_32.ll new file mode 100644 index 0000000..3f0a264 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/lower-ptrmask-arm64_32.ll @@ -0,0 +1,12 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 +; RUN: llc -mtriple=arm64_32-apple-watchos2.0.0 %s -o - | FileCheck %s + +define ptr @issue94075(ptr %p) { +; CHECK-LABEL: issue94075: +; CHECK: ; %bb.0: ; %entry +; CHECK-NEXT: and x0, x0, #0xfffffff8 +; CHECK-NEXT: ret +entry: + %rdar125263567 = call ptr @llvm.ptrmask.p0.i32(ptr %p, i32 4294967288) + ret ptr %rdar125263567 +} |