If we have the code like this:
float a, b; a = std::max(a ,b);
it is converted into something like this:
%call = call dereferenceable(4) float* @_ZSt3maxIfERKT_S2_S2_(float* nonnull dereferenceable(4) %a.addr, float* nonnull dereferenceable(4) %b.addr) %1 = bitcast float* %call to i32* %2 = load i32, i32* %1, align 4 %3 = bitcast float* %a.addr to i32* store i32 %2, i32* %3, align 4
After inlinning this code is converted to the next:
%1 = load float, float* %a.addr %2 = load float, float* %b.addr %cmp.i = fcmp fast olt float %1, %2 %__b.__a.i = select i1 %cmp.i, float* %a.addr, float* %b.addr %3 = bitcast float* %__b.__a.i to i32* %4 = load i32, i32* %3, align 4 %5 = bitcast float* %arrayidx to i32* store i32 %4, i32* %5, align 4
This pattern is not recognized as minmax pattern.
Patch solves this problem by converting sequence
load bitcast (select (Cond, &V1, &V2))
to a sequence
select(Cond, load bitcast &V1, load bitcast &V2)
After this the code is recognized as minmax pattern.