[LLVMbugs] [Bug 12094] New: memcpy from float* should generate aligned load
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Feb 27 02:53:44 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12094
Bug #: 12094
Summary: memcpy from float* should generate aligned load
Product: clang
Version: 3.0
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jay.foad at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
In the example below, a memcpy from "float *p" is turned into an unaligned
load. I think it should be an *aligned* load, because I think clang can assume
that p is suitably aligned.
C99 (Committee Draft -- April 12, 2011) 6.3.2.3-7 says "A pointer to an object
type may be converted to a pointer to a different object type. If the resulting
pointer is not correctly aligned for the referenced type, the behavior is
undefined."
$ cat m.c
#include <string.h>
int f(float *p) {
int i;
memcpy(&i, p, sizeof i);
return i;
}
$ clang -O2 -S -emit-llvm m.c -o -
; ModuleID = 'm.c'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define i32 @f(float* nocapture %p) nounwind uwtable readonly {
entry:
%0 = bitcast float* %p to i32*
%srcval = load i32* %0, align 1
ret i32 %srcval
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list