[PATCH] D23896: [InstCombine] Try to resubmit the combine of A->B->A BitCast and fix for pr27996

Guozhi Wei via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 27 16:06:18 PDT 2016


Carrot added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:1768
@@ +1767,3 @@
+  for (User *U : CI.users()) {
+    if (!isa<StoreInst>(U))
+      return false;
----------------
evstupac wrote:
> Ok.
> You are generating BitCast only for 1 store operand:
> SI->setOperand(0, Builder->CreateBitCast(NewPNodes[PN], SrcTy));
> 
> Here you are exiting if BitCast goes to one of store operand (0 or 1). What is the reason?
Because the following case

bitcast oldval to val
store val, addr

can be handled by InstCombineLoadStoreAlloca.cpp, and transformed to

bitcast addr to addr_with_diff_type
store  oldval, addr_with_diff_type

This is the form you have question. It can be further transformed to

store oldval, (bitcast addr to addr_with_diff_type)

This is an optimized result.



https://reviews.llvm.org/D23896





More information about the llvm-commits mailing list