Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[airconv] expect to eliminate bitcast #5

Closed
3Shain opened this issue Mar 24, 2024 · 1 comment
Closed

[airconv] expect to eliminate bitcast #5

3Shain opened this issue Mar 24, 2024 · 1 comment

Comments

@3Shain
Copy link
Owner

3Shain commented Mar 24, 2024

This

%cast_to_int4_by_need_ = bitcast <4 x float> %0 to <4 x i32>
%value_to_store_after_swizzle_mask_915 = insertelement <4 x i32> %cast_to_int4_by_need_, i32 1065353216, i64 3
%1 = bitcast <4 x i32> %value_to_store_after_swizzle_mask_915 to <4 x float>

is equivalent to

%1 = insertelement <4 x float> %0, float 1.0, i64 3

Although bitcast shouldn't impact the runtime behavior... just curious why llvm -O2 optimization doesn't cover this

@3Shain 3Shain added enhancement help wanted Extra attention is needed labels Mar 24, 2024
@3Shain
Copy link
Owner Author

3Shain commented Apr 4, 2024

A workaround: create an "alias" pointer of float4 array while allocating the register file (which is of int4 array), then we can load/store from/to the alias pointer without problem, and seems llvm can still perfectly promote mem2reg optimization. (which makes sense, since llvm has migrated to opaque pointer type (but we are using an older version of llvm, since the AIR generated by metal still contains typed pointers.

@3Shain 3Shain closed this as completed Apr 4, 2024
@3Shain 3Shain removed enhancement help wanted Extra attention is needed labels Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant