We will still keep the original select if there are multiple uses thus increasing
the number of instructions, so enable this transform for shared selects only when
we can fold the binary op with a select.
Details
Details
- Reviewers
mcrosier majnemer qcolombet mcberg2017
Diff Detail
Diff Detail
Event Timeline
Comment Actions
I think we're on the right track, but what about this test?
declare void @use_float(double) define float @test3(i1 zeroext %arg) #0 { %tmp = select i1 %arg, float 5.000000e+00, float 6.000000e+00 %tmp1 = select i1 %arg, float 1.000000e+00, float 9.000000e+00 %tmp2 = fmul float %tmp, %tmp1 call void @use_double(double %tmp) ret float %tmp2 }
I think we still want to transform this case (because we'll replace the fmul with a select) even though the first select has multiple uses.
lib/Transforms/InstCombine/InstructionCombining.cpp | ||
---|---|---|
740 | I wonder if something like this would work: bool SelectsHaveOneUse = LHS->hasOneUse() && RHS->hasOneUse(); if (V1 && V2) SI = Builder.CreateSelect(A, V2, V1); else if (V2 && SelectsHaveOneUse) SI = Builder.CreateSelect(A, V2, Builder.CreateBinOp(Opcode, C, E)); else if (V1 && SelectsHaveOneUse) SI = Builder.CreateSelect(A, Builder.CreateBinOp(Opcode, B, D), V1); |
lib/Transforms/InstCombine/InstructionCombining.cpp | ||
---|---|---|
740 | An earlier review was opened here: https://reviews.llvm.org/D38263, from which the snippet above originates. Just to let folks know that are two reviews open on this topic. |
I wonder if something like this would work: