Bitwise 'not' of the min/max could be eliminated in the pattern:
%notx = xor i32 %x, -1 %cmp1 = icmp sgt[slt/ugt/ult] i32 %notx, %y %smax = select i1 %cmp1, i32 %notx, i32 %y %res = xor i32 %smax, -1
|  Differential  D45317  
Eliminate a bitwise 'not' op of 'not' min/max by inverting the min/max. Authored by ArturGainullin on Apr 5 2018, 5:54 AM. 
Details Bitwise 'not' of the min/max could be eliminated in the pattern: %notx = xor i32 %x, -1 %cmp1 = icmp sgt[slt/ugt/ult] i32 %notx, %y %smax = select i1 %cmp1, i32 %notx, i32 %y %res = xor i32 %smax, -1 
Diff Detail 
 Event TimelineComment Actions For reference, this pattern came up somewhere in the discussion leading up to D44266, but I can't remember exactly where. We can generalize this - you don't need a constant operand to the min/max for it to be a win:  Comment Actions I think I botched making the permalink: Name: not_max_with_not_operand => %noty = xor i32 %y, -1 
 
 
 Comment Actions LGTM - see inline for a nit. 
 | ||||||||||||||||||||||||||||||||||||