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

Michael Kuperstein via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 17 05:08:55 PST 2015


mkuper added a subscriber: mkuper.
mkuper added a comment.

Can you please include additional context in the diff, as requested above?
(See http://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface for directions.)


================
Comment at: lib/Analysis/ConstantFolding.cpp:1144
@@ +1143,3 @@
+      // fold: icmp (addrspacecast x), y     -> icmp x, y
+      if (CE0->getOpcode() == Instruction::AddrSpaceCast) {
+        Constant *C = CE0->getOperand(0);
----------------
I'm not sure I understand why this is correct.

My understanding of the semantics of addrspacecast is that it may change the integer value of the pointer ("It can be a no-op cast or a complex value modification, depending on the target and the address space pair"). Since icmp on pointers compares integer values ("If the operands are pointer typed, the pointer values are compared as if they were integers."), this transformation may change the result of the comparison.

Am I missing something?

================
Comment at: test/Transforms/InstCombine/OptimizeAddrspaceCast.ll:26
@@ +25,3 @@
+  store i32 %6, i32 addrspace(1)* %8, align 4
+; CHECK: store i32 1, i32 addrspace(1)* %results
+  ret void
----------------
Any chance to reduce the test case? It looks very large, compared to what it's actually checking.


http://reviews.llvm.org/D14721





More information about the llvm-commits mailing list