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.
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.