We are developing prototypes for Intel Advanced Matrix Extensions (AMX)  programing model in Clang and LLVM .
We met several cases when the certain type we added are optimized unexpectedly in the middle-end. E.g. optimizing phi + biscast + load:
%a = load <256 x i32>, <256 x i32>* %mem, align 64
%b = phi <256 x i32> [ %a, %label1 ], [%someother, %label2]
%c = bitcast <256 x i32> %b to x86_amx
%a = bitcast <256 x i32>* %mem to x86_amx*
%b = load x86_amx, x86_amx*, align 64
%c = phi x86_amx [ %b, %label1 ], [%someother, %label2]
To prevent such unexpected transforms, we concretely added the type check in each point of the optimizations.
Roman pointed out the changes are not the right direction , and thought it’s bug for backend. While we agreed backend might be able to handle it for the functionality, we think it is better to handle it in the midden-end since they are negative optimizations for AMX.
First, let me put some background here: