[llvm-bugs] [Bug 27085] New: scalar/vector operations lead to division by zero
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Mar 26 05:44:37 PDT 2016
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: unassignedclangbugs at nondot.org
Reporter: regis.portalez at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160326/fe042da2/attachment.html>
More information about the llvm-bugs
mailing list