[llvm] [IRBuilder] Limit created masked load/store alignment to valid 32bit values (PR #73647)
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 28 06:16:24 PST 2023
================
@@ -584,7 +584,8 @@ CallInst *IRBuilderBase::CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment,
if (!PassThru)
PassThru = PoisonValue::get(Ty);
Type *OverloadedTypes[] = { Ty, PtrTy };
- Value *Ops[] = {Ptr, getInt32(Alignment.value()), Mask, PassThru};
+ unsigned Align32 = std::min<uint64_t>(Alignment.value(), 0x80000000ULL);
----------------
gchatelet wrote:
I would rather use:
```
const Align LimitedAlign = std::min(Alignment, Align(32));
Value *Ops[] = {Ptr, getInt32(LimitedAlign.value()), Mask, PassThru};
```
and possibly encapsulate the logic into a function instead of copy/pasting the code.
https://github.com/llvm/llvm-project/pull/73647
More information about the llvm-commits
mailing list