In PPCTargetLowering::DAGCombineTruncBoolExt, when checking if it's correct to perform the transformation for non-sign comparison, as the comment says
// This is neither a signed nor an unsigned comparison, just make sure // that the high bits are equal.
Origin check
if (Op1Known.Zero != Op2Known.Zero || Op1Known.One != Op2Known.One) return SDValue();
is not strong enough. For example,
Op1Known = 111x000x; Op2Known = 111x000x;
Bit 4, besides bit 0, is still unknown and affects the final result.
This patch fixes https://bugs.llvm.org/show_bug.cgi?id=48388.
Hmm, but we've cleared bit zero from both known zero and known ones for both. So they will both be non-constant, won't they? I think that we would have to rewrite the above lines to something like this: