EarlyCSE pass runs very early at the pipeline of opt binary, before inst combine pass.
For now EarlyCSE pass only recognizes the abs pattern after the canonicalize of abs in instcombine pass. This will make EarlyCSE miss some opportunities.
Also only recognizing some abs pattern will make equal instructions have different hash value. For example, see https://bugs.llvm.org/show_bug.cgi?id=48058
%neg = sub i8 0, %a %cmp1 = icmp slt i8 %a, 0 %cmp2 = icmp sge i8 %a, 0 %m1 = select i1 %cmp1, i8 %a, i8 %neg %m2 = select i1 %cmp2, i8 %neg, i8 %a %r = xor i8 %m2, %m1 ret i8 %r `
%m1 and %m2 are recognized as same instructions in isEqualImpl because of inverse predicate and same operands for these two select.
But in getHashValueImpl, %m1 is recognized as NABS because it is already in canonicalize form of abs. But %m2 is not in canonicalize form of abs, so it is not recognized as NABS.