[clang] [llvm] [IR][Clang] Guard full-width shift in FixedPointBuilder (PR #239969)
Jaeyong Lee via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 9 16:53:25 PST 2026
================
@@ -60,9 +60,13 @@ template <class IRBuilderTy> class FixedPointBuilder {
Result = B.CreateSelect(IsNegative, Rounded, Result);
}
- Result = SrcIsSigned
- ? B.CreateAShr(Result, SrcScale - DstScale, "downscale")
- : B.CreateLShr(Result, SrcScale - DstScale, "downscale");
+ unsigned Shift = SrcScale - DstScale;
+ if (Shift < ResultWidth) {
+ Result = SrcIsSigned ? B.CreateAShr(Result, Shift, "downscale")
+ : B.CreateLShr(Result, Shift, "downscale");
+ } else {
----------------
npmania wrote:
Added in 5ffede85a511f59d6560003e6cd838fda5b9e9d0.
https://github.com/llvm/llvm-project/pull/239969
More information about the cfe-commits
mailing list