Allow two users of the condition if the other user
is also a min/max select. i.e.
%c = icmp slt i32 %x, %y
%min = select i1 %c, i32 %x, i32 %y
%max = select i1 %c, i32 %y, i32 %x
| Paths 
 |  Differential  D20225  
SelectionDAG: Select min/max when both are used ClosedPublic Authored by arsenm on May 12 2016, 6:47 PM. 
Details 
 Summary Allow two users of the condition if the other user %c = icmp slt i32 %x, %y 
Diff Detail Event Timelinearsenm updated this object. jmolloy edited edge metadata.Comment Actions Hi, Generally looks fine as-is, but I think the helper can be simplified a bit. James 
 This revision is now accepted and ready to land.May 13 2016, 1:15 AM 
 
 
Revision Contents 
 
Diff 57126 lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
 
 test/CodeGen/AMDGPU/select-i1.ll
 test/CodeGen/AMDGPU/sminmax.ll
 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I think this can be written simpler. Is it important that we bail out for > 2 users? If we have > 2 users of an icmp that are both selects, surely one would have been CSEd before now?
So we could just do:
static bool hasOnlySelectUsers(Value *Cond) { return std::all_of(Cond->user_begin(), Cond->user_end(), [](Value *V) { return isa<SelectInst>(V); }); }?