https://llvm.org/bugs/show_bug.cgi?id=27085
Bug ID: 27085
Summary: scalar/vector operations lead to division by zero
Product: clang
Version: 3.7
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
try to compile the following code (C) using clang 3.7 (using only mem2reg pass)
typedef unsigned char char4 __attribute__ ((vector_size (4)));
char4 f1 (char4 v)
{
return v / 2;
}
this compiles down to (+ debug info):
define <4 x i8> @f1(<4 x i8> %v) {
entry:
%div = udiv <4 x i8> %v, bitcast (<1 x i32> <i32 2> to <4 x i8>)
ret <4 x i8> %div
}
according to http://llvm.org/docs/LangRef.html#bitcast-to-instruction, bitcast
instruction does not change any bit, meaning bitcast (<1 x i32> <i32 2> to <4 x
i8>) returns <2, 0, 0, 0> as char vector.
therefore the division in the original source code generates a division by
zero.
I would have expected the following IL:
define <4 x i8> @f1(<4 x i8> %v) {
entry:
%div = udiv <4 x i8> %v, <4 x i8> <i8 2, i8 2, i8 2, i8 2>
ret <4 x i8> %div
}
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs