[PATCH] D135249: [AggressiveInstCombine] Fix cases where non-opaque pointers are used

David Stuttard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 05:44:02 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1d7d2235ced: [AggressiveInstCombine] Fix cases where non-opaque pointers are used (authored by dstuttard).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135249

Files:
  llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp


Index: llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
===================================================================
--- llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -795,9 +795,9 @@
   IRBuilder<> Builder(&I);
   LoadInst *NewLoad = nullptr, *LI1 = LOps.Root;
 
+  IntegerType *WiderType = IntegerType::get(I.getContext(), LOps.LoadSize);
   // TTI based checks if we want to proceed with wider load
-  bool Allowed =
-      TTI.isTypeLegal(IntegerType::get(I.getContext(), LOps.LoadSize));
+  bool Allowed = TTI.isTypeLegal(WiderType);
   if (!Allowed)
     return false;
 
@@ -811,9 +811,9 @@
   // New load can be generated
   Value *Load1Ptr = LI1->getPointerOperand();
   Builder.SetInsertPoint(LI1);
-  NewLoad = Builder.CreateAlignedLoad(
-      IntegerType::get(Load1Ptr->getContext(), LOps.LoadSize), Load1Ptr,
-      LI1->getAlign(), LI1->isVolatile(), "");
+  Value *NewPtr = Builder.CreateBitCast(Load1Ptr, WiderType->getPointerTo(AS));
+  NewLoad = Builder.CreateAlignedLoad(WiderType, NewPtr, LI1->getAlign(),
+                                      LI1->isVolatile(), "");
   NewLoad->takeName(LI1);
   // Set the New Load AATags Metadata.
   if (LOps.AATags)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135249.465355.patch
Type: text/x-patch
Size: 1299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221005/cb87240b/attachment.bin>


More information about the llvm-commits mailing list