llvm-project
baac97e1 - [ConstantFolding] Fold constant vector `bitcast`s to scalar bytes (#242811)

Commit
7 hours ago
[ConstantFolding] Fold constant vector `bitcast`s to scalar bytes (#242811) #188030 added `bitcast` constant folding for byte types. This PR handles vector to scalar byte `bitcast`s. Constant fold vector `bitcast`s to scalar bytes. - A vector of integers or floating-point values folds to a byte constant with the same bits. - A vector with a `poison` element isn't folded, as a byte constant can't represent partial `poison` values. - A vector of pointers isn't folded, as a byte constant can't represent pointer provenance. - A vector of bytes with an element that isn't a plain constant, like a pointer, isn't folded, as it would drop provenance. ```llvm %a = bitcast <2 x i32> <i32 1, i32 2> to b64 ; b64 8589934593 %b = bitextract i8, b64 %a, i32 32 ; i8 2 %c = bitcast <2 x i32> <i32 1, i32 poison> to b64 ; unchanged ```
Author
Parents
Loading