mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
SystemZ: Avoid left shifting negative values (it's UB)
Found by ubsan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240420 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
896353d663
commit
3800e768a2
@ -2005,17 +2005,17 @@ static Comparison getIntrinsicCmp(SelectionDAG &DAG, unsigned Opcode,
|
||||
else if (Cond == ISD::SETLT || Cond == ISD::SETULT)
|
||||
// bits above bit 3 for CC==0 (always false), bits above bit 0 for CC==3,
|
||||
// always true for CC>3.
|
||||
C.CCMask = CC < 4 ? -1 << (4 - CC) : -1;
|
||||
C.CCMask = CC < 4 ? ~0U << (4 - CC) : -1;
|
||||
else if (Cond == ISD::SETGE || Cond == ISD::SETUGE)
|
||||
// ...and the inverse of that.
|
||||
C.CCMask = CC < 4 ? ~(-1 << (4 - CC)) : 0;
|
||||
C.CCMask = CC < 4 ? ~(~0U << (4 - CC)) : 0;
|
||||
else if (Cond == ISD::SETLE || Cond == ISD::SETULE)
|
||||
// bit 3 and above for CC==0, bit 0 and above for CC==3 (always true),
|
||||
// always true for CC>3.
|
||||
C.CCMask = CC < 4 ? -1 << (3 - CC) : -1;
|
||||
C.CCMask = CC < 4 ? ~0U << (3 - CC) : -1;
|
||||
else if (Cond == ISD::SETGT || Cond == ISD::SETUGT)
|
||||
// ...and the inverse of that.
|
||||
C.CCMask = CC < 4 ? ~(-1 << (3 - CC)) : 0;
|
||||
C.CCMask = CC < 4 ? ~(~0U << (3 - CC)) : 0;
|
||||
else
|
||||
llvm_unreachable("Unexpected integer comparison type");
|
||||
C.CCMask &= CCValid;
|
||||
|
Loading…
Reference in New Issue
Block a user