<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Same. LGTM.<br>
<br>
I take it you're going to canonicalize assumptions about alignment
as align attributes where possible?<br>
<br>
Philip<br>
<br>
On 07/22/2014 09:31 AM, Chandler Carruth wrote:<br>
</div>
<blockquote
cite="mid:CAGCO0KjUkoammimm1FERt2RXLauFH=ZHnCo=FSKErcyA+TcvAw@mail.gmail.com"
type="cite">
<p dir="ltr">LGTM, seems like obvious goodness to me.</p>
<div class="gmail_quote">On Jul 22, 2014 9:04 AM, "<a
moz-do-not-send="true" href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>"
<<a moz-do-not-send="true" href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>>
wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi chandlerc, reames, aschwaighofer, nadav,<br>
<br>
This is almost more of a documentation change than anything
else...<br>
<br>
We currently support the align attribute on all (pointer)
parameters, but we only use it for byval parameters. However,
it is completely consistent at the IR level to treat 'align n'
on all pointer parameters as an alignment assumption on the
pointer. This patch does this:<br>
<br>
1. Causes computeKnownBits to use the align attribute on all
pointer parameters, not just byval parameters.<br>
2. Updated the LangRef to document the align parameter
attribute (as it turns out, it was not documented at all
previously, although the byval documentation mentioned that it
could be used).<br>
<br>
There are two benefits to doing this:<br>
1. It allows enhancing alignment based on the pointer
alignment after inlining<br>
2. It allows simplification of pointer arithmetic<br>
<br>
My primary use case for these things involves pointers that
are over-aligned to allow for efficient vectorized code
generation.<br>
<br>
Thanks again!<br>
<br>
<a moz-do-not-send="true" href="http://reviews.llvm.org/D4620"
target="_blank">http://reviews.llvm.org/D4620</a><br>
<br>
Files:<br>
docs/LangRef.rst<br>
lib/Analysis/ValueTracking.cpp<br>
test/Bitcode/attributes.ll<br>
test/Transforms/InstCombine/align-attr.ll<br>
<br>
Index: docs/LangRef.rst<br>
===================================================================<br>
--- docs/LangRef.rst<br>
+++ docs/LangRef.rst<br>
@@ -921,6 +921,13 @@<br>
the first parameter. This is not a valid attribute for
return<br>
values.<br>
<br>
+``align <n>``<br>
+ This indicates that the pointer value may be assumed by
the optimizer to<br>
+ have the specified alignment.<br>
+<br>
+ Note that this attribute has additional semantics when
combined with the<br>
+ ``byval`` attribute.<br>
+<br>
.. _noalias:<br>
<br>
``noalias``<br>
Index: lib/Analysis/ValueTracking.cpp<br>
===================================================================<br>
--- lib/Analysis/ValueTracking.cpp<br>
+++ lib/Analysis/ValueTracking.cpp<br>
@@ -308,13 +308,9 @@<br>
}<br>
<br>
if (Argument *A = dyn_cast<Argument>(V)) {<br>
- unsigned Align = 0;<br>
+ unsigned Align = A->getType()->isPointerTy() ?
A->getParamAlignment() : 0;<br>
<br>
- if (A->hasByValOrInAllocaAttr()) {<br>
- // Get alignment information off byval/inalloca
arguments if specified in<br>
- // the IR.<br>
- Align = A->getParamAlignment();<br>
- } else if (TD && A->hasStructRetAttr()) {<br>
+ if (!Align && TD &&
A->hasStructRetAttr()) {<br>
// An sret parameter has at least the ABI alignment of
the return type.<br>
Type *EltTy =
cast<PointerType>(A->getType())->getElementType();<br>
if (EltTy->isSized())<br>
Index: test/Bitcode/attributes.ll<br>
===================================================================<br>
--- test/Bitcode/attributes.ll<br>
+++ test/Bitcode/attributes.ll<br>
@@ -239,6 +239,11 @@<br>
ret i8* %a<br>
}<br>
<br>
+define void @f41(i8* align 32, double* align 64) {<br>
+; CHECK: define void @f41(i8* align 32, double* align 64) {<br>
+ ret void<br>
+}<br>
+<br>
; CHECK: attributes #0 = { noreturn }<br>
; CHECK: attributes #1 = { nounwind }<br>
; CHECK: attributes #2 = { readnone }<br>
Index: test/Transforms/InstCombine/align-attr.ll<br>
===================================================================<br>
--- /dev/null<br>
+++ test/Transforms/InstCombine/align-attr.ll<br>
@@ -0,0 +1,15 @@<br>
+; RUN: opt < %s -instcombine -S | FileCheck %s<br>
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"<br>
+target triple = "x86_64-unknown-linux-gnu"<br>
+<br>
+; Function Attrs: nounwind uwtable<br>
+define i32 @foo1(i32* align 32 %a) #0 {<br>
+entry:<br>
+ %0 = load i32* %a, align 4<br>
+ ret i32 %0<br>
+<br>
+; CHECK-LABEL: @foo1<br>
+; CHECK-DAG: load i32* %a, align 32<br>
+; CHECK: ret i32<br>
+}<br>
+<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a moz-do-not-send="true"
href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a moz-do-not-send="true"
href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits"
target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br>
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>