Skip to content

Commit

Permalink
Fix C4146
Browse files Browse the repository at this point in the history
```
warning C4146: unary minus operator applied to unsigned type, result still unsigned
```
  • Loading branch information
fjeremic committed Jun 7, 2021
1 parent ab19e76 commit d1f5435
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/codegen/OMRCodeGenerator.cpp
Expand Up @@ -2236,7 +2236,7 @@ OMR::CodeGenerator::computeUnsigned64BitMagicValues(uint64_t d, int32_t* s, int3
uint64_t nc, delta, q1, r1, q2, r2;

*a = 0; /* initialize "add" indicator */
nc = -1 - (-d)%d;
nc = -1 - ((~d) + 1)%d;
p = 63; /* initialize p */
q1 = 0x8000000000000000ull/nc; /* initialize 2**p/nc */
r1 = 0x8000000000000000ull- q1*nc; /* initialize rem(2**p,nc) */
Expand Down
4 changes: 2 additions & 2 deletions compiler/optimizer/VPHandlers.cpp
Expand Up @@ -6931,7 +6931,7 @@ TR::Node *constrainIabs(OMR::ValuePropagation *vp, TR::Node *node)
{
int32_t value = low;
if (value < 0)
value = -(uint32_t)value;
value = -value;

TR::VPConstraint *constraint = TR::VPIntConst::create(vp, value);
vp->replaceByConstant(node, constraint, isGlobal);
Expand Down Expand Up @@ -7008,7 +7008,7 @@ TR::Node *constrainLabs(OMR::ValuePropagation *vp, TR::Node *node)
{
int64_t value = low;
if (value < 0)
value = -(uint64_t)value;
value = -value;

TR::VPConstraint *constraint = TR::VPLongConst::create(vp, value);
vp->replaceByConstant(node, constraint, isGlobal);
Expand Down
4 changes: 2 additions & 2 deletions compiler/x/amd64/codegen/AMD64SystemLinkage.cpp
Expand Up @@ -900,10 +900,10 @@ TR::AMD64ABILinkage::mapIncomingParms(
{
uint32_t align = getAlignment(parmCursor->getDataType());
uint32_t alignMinus1 = (align <= AMD64_STACK_SLOT_SIZE) ? (AMD64_STACK_SLOT_SIZE - 1) : (align - 1);
uint32_t pos = -stackIndex;
uint32_t pos = (~stackIndex) + 1;
pos += static_cast<uint32_t>(parmCursor->getSize());
pos = (pos + alignMinus1) & (~alignMinus1);
stackIndex = -pos;
stackIndex = (~pos) + 1;
parmCursor->setParameterOffset(stackIndex);

if (comp()->getOption(TR_TraceCG))
Expand Down

0 comments on commit d1f5435

Please sign in to comment.