<div dir="ltr"><div>Looks broken to me - we need to consider big/little-endian datalayout when bitcasting to/from vectors.</div><div>We should have some documentation for this in the LangRef, but I don't see anything currently.</div><div><br></div><div>The transform in question was added here:</div><div><a href="https://reviews.llvm.org/rL103354">https://reviews.llvm.org/rL103354</a></div><div><br></div><div>You can find other vector bitcast transforms that (hopefully correctly...) account for the datalayout difference for vector elements.</div><div><br></div><div>Example:<br></div><div><a href="https://github.com/llvm/llvm-project/blob/master/llvm/test/Transforms/InstCombine/bitcast-bigendian.ll#L10">https://github.com/llvm/llvm-project/blob/master/llvm/test/Transforms/InstCombine/bitcast-bigendian.ll#L10</a></div><div><a href="https://github.com/llvm/llvm-project/blob/master/llvm/test/Transforms/InstCombine/bitcast.ll#L290">https://github.com/llvm/llvm-project/blob/master/llvm/test/Transforms/InstCombine/bitcast.ll#L290</a></div><div><br></div><div>So we need something like this:</div><div><a href="https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L487">https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp#L487</a></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 28, 2019 at 9:12 AM Mikael Holmén via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
In<br>
llvm/test/Transforms/InstCombine/cast.ll<br>
there is a test like this:<br>
<br>
target datalayout = "E-p:64:64:64-p1:32:32:32-p2:64:64:64-p3:64:64:64-<br>
a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-<br>
v64:64:64-v128:128:128-n8:16:32:64"<br>
<br>
[...]<br>
<br>
define <3 x i32> @test60(<4 x i32> %call4) {<br>
; CHECK-LABEL: @test60(<br>
; CHECK-NEXT: [[P10:%.*]] = shufflevector <4 x i32> [[CALL4:%.*]],<br>
<4 x i32> undef, <3 x i32> <i32 0, i32 1, i32 2><br>
; CHECK-NEXT: ret <3 x i32> [[P10]]<br>
;<br>
%p11 = bitcast <4 x i32> %call4 to i128<br>
%p9 = trunc i128 %p11 to i96<br>
%p10 = bitcast i96 %p9 to <3 x i32><br>
ret <3 x i32> %p10<br>
<br>
}<br>
<br>
If we assume the input vector is e.g. <1, 2, 3, 4> then I assume %p11<br>
would be the (hex) value 1234, %p9 would be the 234 and %p10 would then<br>
be the vector <2, 3, 4>.<br>
<br>
Am I right, or am I missing something here? Note that the datalayout<br>
says we're using big endian.<br>
<br>
But the CHECK-NEXT checks that the result is made up of the elements at<br>
index 0, 1 and 2 from the input vector, which would be <1, 2, 3>.<br>
<br>
So, broken testcase or am I missing something?<br>
<br>
Thanks,<br>
Mikael<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>