[PATCH] D139962: [InstCombine] Support vectors in simplifyIntToPtrRoundTripCast.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 12:06:38 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd08e3ae271a9: [InstCombine] Support vectors in simplifyIntToPtrRoundTripCast. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139962/new/

https://reviews.llvm.org/D139962

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll


Index: llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll
===================================================================
--- llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll
+++ llvm/test/Transforms/InstCombine/ptr-int-ptr-icmp.ll
@@ -17,6 +17,28 @@
   ret i1 %cmp
 }
 
+define <2 x i1> @func_vec(<2 x ptr> %X, <2 x ptr> %Y) {
+; CHECK-LABEL: @func_vec(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x ptr> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %i = ptrtoint <2 x ptr> %X to <2 x i64>
+  %p = inttoptr <2 x i64> %i to <2 x ptr>
+  %cmp = icmp eq <2 x ptr> %p, %Y
+  ret <2 x i1> %cmp
+}
+
+define <vscale x 2 x i1> @func_svec(<vscale x 2 x ptr> %X, <vscale x 2 x ptr> %Y) {
+; CHECK-LABEL: @func_svec(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <vscale x 2 x ptr> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT:    ret <vscale x 2 x i1> [[CMP]]
+;
+  %i = ptrtoint <vscale x 2 x ptr> %X to <vscale x 2 x i64>
+  %p = inttoptr <vscale x 2 x i64> %i to <vscale x 2 x ptr>
+  %cmp = icmp eq <vscale x 2 x ptr> %p, %Y
+  ret <vscale x 2 x i1> %cmp
+}
+
 define i1 @func_pointer_different_types(ptr %X, ptr %Y) {
 ; CHECK-LABEL: @func_pointer_different_types(
 ; CHECK-NEXT:    [[CMP:%.*]] = icmp eq ptr [[X:%.*]], [[Y:%.*]]
Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -370,14 +370,14 @@
 // inttoptr ( ptrtoint (x) ) --> x
 Value *InstCombinerImpl::simplifyIntToPtrRoundTripCast(Value *Val) {
   auto *IntToPtr = dyn_cast<IntToPtrInst>(Val);
-  if (IntToPtr && DL.getPointerTypeSizeInBits(IntToPtr->getDestTy()) ==
+  if (IntToPtr && DL.getTypeSizeInBits(IntToPtr->getDestTy()) ==
                       DL.getTypeSizeInBits(IntToPtr->getSrcTy())) {
     auto *PtrToInt = dyn_cast<PtrToIntInst>(IntToPtr->getOperand(0));
     Type *CastTy = IntToPtr->getDestTy();
     if (PtrToInt &&
         CastTy->getPointerAddressSpace() ==
             PtrToInt->getSrcTy()->getPointerAddressSpace() &&
-        DL.getPointerTypeSizeInBits(PtrToInt->getSrcTy()) ==
+        DL.getTypeSizeInBits(PtrToInt->getSrcTy()) ==
             DL.getTypeSizeInBits(PtrToInt->getDestTy())) {
       return CastInst::CreateBitOrPointerCast(PtrToInt->getOperand(0), CastTy,
                                               "", PtrToInt);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139962.482584.patch
Type: text/x-patch
Size: 2442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221213/58a9da41/attachment.bin>


More information about the llvm-commits mailing list