[PATCH] D16069: AMDGPU: Implement {{s|u}}int_to_fp i64 -> f32

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 11 10:35:10 PST 2016


nhaehnle added a subscriber: nhaehnle.
nhaehnle added a comment.

Other than the removed test, LGTM.


================
Comment at: lib/Target/AMDGPU/AMDGPUISelLowering.cpp:2233-2236
@@ +2232,6 @@
+  //  uint e = (u != 0) ? 127U + 63U - lz : 0;
+  //  u = (u << lz) & 0x7fffffffffffffffUL;
+  //  ulong t = u & 0xffffffffffUL;
+  //  uint v = (e << 23) | (uint)(u >> 40);
+  //  uint r = t > 0x8000000000UL ? 1U : (t == 0x8000000000UL ? v & 1U : 0U);
+  //  return as_float(v + r);
----------------
I was thinking a bit about this because of all the i64, but it quickly gets messy and it's not clear to me that there is a much better way. I wonder whether bitcasting u to v2i32 and only shifting the high dword by 8 results in better code, but I'm fine with not trying that.

================
Comment at: test/CodeGen/AMDGPU/uint_to_fp.ll:124-132
@@ -123,11 @@
-
-; R600: UINT_TO_FLT
-; R600: UINT_TO_FLT
-; R600: MULADD_IEEE
-define void @s_uint_to_fp_i64_to_f32(float addrspace(1)* %out, i64 %in) #0 {
-entry:
-  %cvt = uitofp i64 %in to float
-  store float %cvt, float addrspace(1)* %out
-  ret void
-}
-
----------------
I think the R600 variant of the test should stay.


http://reviews.llvm.org/D16069





More information about the llvm-commits mailing list