[clang] [llvm] [InstCombine] Add canonicalization of `sitofp` -> `uitofp nneg` (PR #88299)
Yingwei Zheng via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 17 00:23:16 PDT 2024
================
@@ -1964,11 +1964,25 @@ Instruction *InstCombinerImpl::visitFPToSI(FPToSIInst &FI) {
}
Instruction *InstCombinerImpl::visitUIToFP(CastInst &CI) {
- return commonCastTransforms(CI);
+ if (Instruction *R = commonCastTransforms(CI))
+ return R;
+ if (!CI.hasNonNeg() && isKnownNonNegative(CI.getOperand(0), SQ)) {
+ CI.setNonNeg();
+ return &CI;
+ }
+ return nullptr;
}
Instruction *InstCombinerImpl::visitSIToFP(CastInst &CI) {
- return commonCastTransforms(CI);
+ if (Instruction *R = commonCastTransforms(CI))
+ return R;
+ if (isKnownNonNegative(CI.getOperand(0), SQ)) {
+ auto UI =
----------------
dtcxzyw wrote:
@goldsteinn We always use `auto *` for pointers.
https://llvm.org/docs/CodingStandards.html#beware-unnecessary-copies-with-auto
https://github.com/llvm/llvm-project/pull/88299
More information about the cfe-commits
mailing list