[llvm] [llubi] Add support for bitcast (PR #185205)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 7 09:16:59 PST 2026
================
@@ -0,0 +1,49 @@
+; NOTE: Assertions have been autogenerated by utils/update_llubi_test_checks.py UTC_ARGS: --version 6
+; RUN: llubi --verbose < %s 2>&1 | FileCheck %s
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
+
+define void @main() {
+entry:
+ %bitcast_int2int = bitcast i32 1 to i32
+ %bitcast_int2int_poison = bitcast i32 poison to i32
+ %bitcast_int2float = bitcast i32 0 to float
+ %bitcast_float2float = bitcast float 2.0 to float
+ %bitcast_float2int = bitcast float 2.0 to i32
+ %bitcast_half2bf16 = bitcast half 1.0 to bfloat
+ %ptr = alloca i32
+ ; FIXME: The provenance is lost.
+ %bitcast_ptr2ptr = bitcast ptr %ptr to ptr
+
+ %bitcast_vec2scalar = bitcast <2 x i32> <i32 0, i32 1> to i64
+ %bitcast_scalar2vec = bitcast i64 1 to <2 x i32>
+ %bitcast_vec2scalar_partial_poison = bitcast <2 x i32> <i32 poison, i32 0> to i64
+ %bitcast_scalar2vec_poison = bitcast i64 poison to <2 x i32>
+
+ %bitcast_vec2vec_up = bitcast <2 x i32> <i32 1, i32 poison> to <4 x i16>
+ %bitcast_vec2vec_down = bitcast <4 x i16> <i16 0, i16 poison, i16 2, i16 3> to <2 x i32>
+ %bitcast_vec2vec_weird = bitcast <8 x i3> <i3 0, i3 1, i3 2, i3 3, i3 4, i3 5, i3 6, i3 7> to <3 x i8>
+
+ %bitcast_intvec2floatvec = bitcast <2 x i32> <i32 1, i32 2> to <4 x half>
+ %bitcast_floatvec2int = bitcast <4 x half> <half 1.0, half 2.0, half 3.0, half 4.0> to i64
+ ret void
+}
+; CHECK: Entering function: main
+; CHECK-NEXT: %bitcast_int2int = bitcast i32 1 to i32 => i32 1
+; CHECK-NEXT: %bitcast_int2int_poison = bitcast i32 poison to i32 => poison
+; CHECK-NEXT: %bitcast_int2float = bitcast i32 0 to float => 0
+; CHECK-NEXT: %bitcast_float2float = bitcast float 2.000000e+00 to float => 2
----------------
nikic wrote:
It's weird that integers get the `iN` type prefix but floats don't. Just looking at the result it's not obvious that this is a float and not an integer.
https://github.com/llvm/llvm-project/pull/185205
More information about the llvm-commits
mailing list