[PATCH] D14721: patch for missed constantFold optimization in InstCombine

Mandeep Singh Grang via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 20 11:53:01 PST 2015


mgrang added a subscriber: mgrang.

================
Comment at: lib/Analysis/ConstantFolding.cpp:1141
@@ +1140,3 @@
+      
+      // ConstantFold a compare instruction with addrspacecast as the
+      // first operand.
----------------
Ideally it's best to submit the entire file containing your changes. I would do this as follows:

git diff <previous_commit_id> HEAD -U99999 > my.patch

================
Comment at: lib/Analysis/ConstantFolding.cpp:1142
@@ +1141,3 @@
+      // ConstantFold a compare instruction with addrspacecast as the
+      // first operand.
+      // fold: icmp (addrspacecast x), y         -> icmp x, y
----------------
Maximize the 80 column line width here.

================
Comment at: lib/Analysis/ConstantFolding.cpp:1147
@@ +1146,3 @@
+          Constant *Null = Constant::getNullValue(C->getType());
+          return ConstantFoldCompareInstOperands(Predicate, C, Null, TD, TLI);
+      }
----------------
meadori wrote:
> Is this patch against mainline trunk?
> 
> Invocations of `ConstantFoldCompareInstOperands` that I see look like:
> 
> ```
> ConstantFoldCompareInstOperands(Predicate, C, Null, DL, TLI);
> ```
Your patch seems to be based on an older version of code. In the latest tip the signature of ConstantFoldCompareInstOperands does not use "TD". It uses DataLayout (DL) instead:

return ConstantFoldCompareInstOperands(Predicate, C, Null, DL, TLI);

================
Comment at: test/Transforms/InstCombine/instCombineOptimizeAddrspaceCast.ll:1
@@ +1,2 @@
+; Test to make sure that the addrspacecast is constantfolded correctly
+; during InstCombine pass.
----------------
The test name does not need to contain "instCombine". It can simply be called OptimizeAddrspaceCast.ll


http://reviews.llvm.org/D14721





More information about the llvm-commits mailing list