[clang] [SveEmitter] Explicitly merge with `poison` instead of `undef` (PR #124596)

Pedro Lobo via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 31 10:54:39 PST 2025


pedroclobo wrote:

Thanks for the heads-up! I've skimmed through the [Arm Architecture Reference Manual for A-profile architecture](https://developer.arm.com/documentation/ddi0487/latest/) but what I've found is rather inconclusive.

Section B1.4.5.3 states that "_Merging predication is performed when Inactive elements in the destination register retain their previous value._". The description of each of the changed builtins just mentions that merging predication should be performed. Merging with `poison` would only be problematic if a non-predicated instruction ends up processing the inactive elements in some way, potentially observing distinct values at each use. I'm not sure if this is frequent or even possible by reading the reference manual, but I would not be surprised if it is. 

My interpretation suggests that we should instead merge with a deterministic value (to be on the safe side), such as `freeze(poison)`, in order to _retain the previous value_ and prevent the problem I mentioned above. We could also use `zeroinitializer` but `freeze(poison)` seems to be more semantically aligned with what the manual specifies.

https://github.com/llvm/llvm-project/pull/124596


More information about the cfe-commits mailing list