[llvm] [ConstraintElimination] Extend unsigned-to-signed fact transfer (PR #66173)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 18 15:32:39 PDT 2023
================
@@ -748,13 +749,23 @@ void ConstraintInfo::transferToOtherSystem(
default:
break;
case CmpInst::ICMP_ULT:
- // If B is a signed positive constant, A >=s 0 and A <s B.
+ case CmpInst::ICMP_ULE:
+ // If B is a signed positive constant, A >=s 0 and A <s (or <=s) B.
if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), 0))) {
addFact(CmpInst::ICMP_SGE, A, ConstantInt::get(B->getType(), 0), NumIn,
NumOut, DFSInStack);
- addFact(CmpInst::ICMP_SLT, A, B, NumIn, NumOut, DFSInStack);
+ addFact(CmpInst::getSignedPredicate(Pred), A, B, NumIn, NumOut,
+ DFSInStack);
}
break;
+ case CmpInst::ICMP_UGE:
+ case CmpInst::ICMP_UGT:
+ // If A and B are signed positive constants, A >s (or >=s) B.
+ if (doesHold(CmpInst::ICMP_SGE, B, ConstantInt::get(B->getType(), 0)) &&
+ doesHold(CmpInst::ICMP_SGE, A, ConstantInt::get(B->getType(), 0)))
----------------
antoniofrighetto wrote:
I'm not really sure why I was constraining B as well. Indeed, if $A \geq_{u} B \land A \geq_{s} 0$ holds and, e.g., $A$ and $B$ are 8-bit integers, then $A$ is in $[0, 127]$, therefore $B >= 0$ must hold. Fixed, thanks.
https://github.com/llvm/llvm-project/pull/66173
More information about the llvm-commits
mailing list