https://github.com/dtcxzyw closed
https://github.com/llvm/llvm-project/pull/87910
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -897,7 +897,20 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst
&Trunc) {
}
}
- return nullptr;
+ bool Changed = false;
+ if (!Trunc.hasNoSignedWrap() &&
+ ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) {
+Trunc.setHasNoSignedWrap
https://github.com/nikic approved this pull request.
LGTM
https://github.com/llvm/llvm-project/pull/87910
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/87910
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -897,7 +897,20 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst
&Trunc) {
}
}
- return nullptr;
+ bool Changed = false;
+ if (!Trunc.hasNoSignedWrap() &&
+ ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) {
+Trunc.setHasNoSignedWrap
@@ -897,7 +897,20 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst
&Trunc) {
}
}
- return nullptr;
+ bool Changed = false;
+ if (!Trunc.hasNoSignedWrap() &&
+ ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) {
+Trunc.setHasNoSignedWrap
@@ -897,7 +897,20 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst
&Trunc) {
}
}
- return nullptr;
+ bool Changed = false;
+ if (!Trunc.hasNoSignedWrap() &&
+ ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) {
+Trunc.setHasNoSignedWrap
@@ -897,7 +897,20 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst
&Trunc) {
}
}
- return nullptr;
+ bool Changed = false;
+ if (!Trunc.hasNoSignedWrap() &&
+ ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) {
+Trunc.setHasNoSignedWrap
@@ -897,7 +897,20 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst
&Trunc) {
}
}
- return nullptr;
+ bool Changed = false;
+ if (!Trunc.hasNoSignedWrap() &&
+ ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) {
+Trunc.setHasNoSignedWrap
goldsteinn wrote:
LGTM.
https://github.com/llvm/llvm-project/pull/87910
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
goldsteinn wrote:
Not an issue now but I think we should look into updating
`computeKnownBitsFromContext` to look use `trunc nsw/nuw` uses of `X`. If the
use is dominating / noundef, we can infer bits about `X`.
Not really an issue if we only use `KnownBits` to infer `nuw`/`nsw`, but once
we a
@@ -897,7 +897,20 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst
&Trunc) {
}
}
- return nullptr;
+ bool Changed = false;
+ if (!Trunc.hasNoSignedWrap() &&
+ ComputeMaxSignificantBits(Src, /*Depth=*/0, &Trunc) <= DestWidth) {
+Trunc.setHasNoSignedWrap
12 matches
Mail list logo