[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
Fri Dec 1 12:06:05 PST 2017
spatel added a comment.
If we require matching the loads + cmp ahead of the select, then this should be the minimal test case:
define void @bitcasted_minmax_with_select_of_pointers(float* %loadaddr1, float* %loadaddr2, float* %storeaddr) {
%ld1 = load float, float* %loadaddr1, align 4
%ld2 = load float, float* %loadaddr2, align 4
%cond = fcmp ogt float %ld1, %ld2
%sel = select i1 %cond, float* %loadaddr1, float* %loadaddr2
%int_load_addr = bitcast float* %sel to i32*
%ld = load i32, i32* %int_load_addr, align 4
%int_store_addr = bitcast float* %storeaddr to i32*
store i32 %ld, i32* %int_store_addr, align 4
ret void
}
...but I'm not getting the transform to fire. Something may be wrong with the pattern matching's use of m_Specific()?
================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:567-568
+namespace {
+template <typename Op_t> struct LoadClass_match {
+ Op_t Op;
+
----------------
Could make this generally available by putting it into PatternMatch.h?
================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:591-592
+ // Ignore all bitcasts.
+ while (auto *BC = dyn_cast<BitCastInst>(V))
+ V = BC->getOperand(0);
+ // Check that select is select ((cmp load V1, load V2), V1, V2) - minmax
----------------
I don't think we need to loop here. Use peekThroughBitcast() instead.
https://reviews.llvm.org/D40304
More information about the llvm-commits
mailing list