[PATCH] D85804: [AMDGPU] Fix crash when dag-combining bitcast

Ruiling, Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 06:28:15 PDT 2020


ruiling added inline comments.


================
Comment at: llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.ll:306
+define amdgpu_kernel void @bitcast_f32_to_v1i32(i32 addrspace(1)* %out) {
+  %f16 = call arcp afn half @llvm.canonicalize.f16(half 0xH03F0)
+  %f32 = fpext half %f16 to float
----------------
arsenm wrote:
> Does this need the constant canonicalize? I'd rather avoid relying on some specific constant folding behavior.
> 
> I'm also not sure how this produces a 64-bit value
I am not sure why the constant canonicalize was generated right now. The IR in the test-case will become a bitcast from fp32 constant to <1 x i32> in SelectionDAG, I cannot directly make an IR to bitcast a constantfp to <1 x i32>, that will be directly optimized off as a i32 constant after optimization. The code here checking for break condition is wrong, a bitcast from constantfp to <1 x i32> should not execute this piece of code handling 64bit bitcast. It should break-away early. But the break-condition checking expression is false because the DestVT is vector. So a 32bit bitcast goes into if (ConstantFPSDNode *C = dyn_cast<ConstantFPSDNode>(Src)). That's why I modify the break-condition check from && to ||. I think a bitcast from fp32 constant to <2 x i16> or fp32 constant cast to <4 x i8> also need such fix.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85804/new/

https://reviews.llvm.org/D85804



More information about the llvm-commits mailing list