[PATCH] D21246: [InstCombine] Add rule to fold away trunc of partial load

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 10 15:24:17 PDT 2016


sanjoy requested changes to this revision.
sanjoy added a comment.
This revision now requires changes to proceed.

Some minor comments inline.


================
Comment at: lib/Analysis/Loads.cpp:388
@@ +387,3 @@
+      // trunc instructions that use only a part of Load.
+      if (LoadPtr == StrippedPtr && LI->getType() == PartialType)
+        return LI;
----------------
Doesn't the atomicity concern above apply here too?

================
Comment at: lib/Analysis/Loads.cpp:429
@@ +428,3 @@
+      if (PartialType && StorePtr == StrippedPtr &&
+          SI->getOperand(0)->getType() == PartialType)
+        return SI->getOperand(0);
----------------
Why not use `CastInst::isBitOrNoopPointerCastable` here as well (same for the load case)?

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:580
@@ -578,1 +579,3 @@
 
+  // When trunc operand is a widened load, see if we can get the value from a previous store/load
+  if (auto *LI = dyn_cast<LoadInst>(Src)) {
----------------
Is this clang-formatted ?

================
Comment at: test/Transforms/InstCombine/trunc.ll:163
@@ -162,1 +162,3 @@
 
+; The trunc can be replaced with the store value.
+declare void @consume(i8) readonly
----------------
Add a store test case, and also one or two negative test cases.


Repository:
  rL LLVM

http://reviews.llvm.org/D21246





More information about the llvm-commits mailing list