[PATCH] D40304: [InstCombine] PR35354: Convert load bitcast (select (Cond, &V1, &V2)) --> select(Cond, load bitcast &V1, load bitcast &V2)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 29 15:18:02 PST 2017
spatel added a subscriber: chandlerc.
spatel added a comment.
For reference, here are the bitcast-adding commit and discussion (cc @chandlerc ):
https://reviews.llvm.org/rL226781
http://lists.llvm.org/pipermail/llvm-dev/2015-January/080956.html
Nobody was sure what regressions would be caused by that change...looks like we found one. :)
I'm still concerned that we're building on a fold that might get removed. Let me propose an alternate idea:
1. Fold the bitcasts out of the 5 instruction sequence starting from visitStoreInst(): store (bitcast (load (bitcast (select ...))))
2. Create an exception to the bitcasting canonicalization for loads fed by a select, so we don't infinite-loop.
So I think we should be able to do this fold without relying on the fold that moves loads above select, so the test case is minimized to:
define void @bitcasted_store(i1 %cond, float* %loadaddr1, float* %loadaddr2, float* %storeaddr) {
%sel = select i1 %cond, float* %loadaddr1, float* %loadaddr2
%int_load_addr = bitcast float* %sel to i32*
%ld = load i32, i32* %int_load_addr
%int_store_addr = bitcast float* %storeaddr to i32*
store i32 %ld, i32* %int_store_addr
ret void
}
https://reviews.llvm.org/D40304
More information about the llvm-commits
mailing list