[llvm] r219135 - [BasicAA] Revert "Revert r218714 - Make better use of zext and sign information."
Nicholas White
n.j.white at gmail.com
Mon Oct 20 02:16:56 PDT 2014
Sorry for the delay, I've been on holiday. Rich - thanks for your repro, it
definitely helps. I've boiled it down to the IR below. %x and %y should be
PartialAlias as they are NoAlias on the first loop iteration and MustAlias
on the second. However, BasicAliasAnalysis as of
b9ce60ff09ce9ddc94862f72d94ed09e4c4a1b49 says that %x and %y NoAlias. The
regression *wasn't* caused by the a false positive in the new analysis the
change introduces. The patch also fixes a bug in the sign extension logic
in the class (see test_sign_extension in the patch), and this fix now
reveals what I believe is a bug in the modulo analysis (I think it's
missing a call to isValueEqualInPotentialCycles). I've included a bit of my
debugging session below, but I'll dig into this new issue myself to see if
I can fix it. Thanks -
Nick
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
@b = global i32 0, align 4
@c = global i32 0, align 4
@d = global i32 0, align 4
@e = global i32* null, align 8
; CHECK-LABEL: main
; CHECK: PartialAlias: i32** %x, i32** %y
define i32 @main() {
%h = alloca [1 x [2 x i32*]], align 16
%.pr = load i32* @d, align 4
%1 = icmp slt i32 %.pr, 2
br i1 %1, label %.lr.ph, label %10
.lr.ph: ; preds = %0
%2 = load i32* @c, align 4
%3 = sext i32 %2 to i64
%d.promoted = load i32* @d, align 4
br label %4
; <label>:4 ; preds = %.lr.ph, %4
%5 = phi i32 [ %d.promoted, %.lr.ph ], [ %8, %4 ]
%6 = phi i32 [ %.pr, %.lr.ph ], [ %8, %4 ]
%7 = sext i32 %6 to i64
%x = getelementptr inbounds [1 x [2 x i32*]]* %h, i64 0, i64 %3, i64 %7
store i32* @b, i32** %x, align 8
%8 = add nsw i32 %5, 1
%9 = icmp slt i32 %8, 2
br i1 %9, label %4, label %10
; <label>:10 ; preds = %._crit_edge, %0
%y = getelementptr inbounds [1 x [2 x i32*]]* %h, i64 0, i64 0, i64 1
%11 = load i32** %y, align 8
store i32* %11, i32** @e, align 8
ret i32 0
}
And my debugging session:
$ lldb -- ./Debug+Asserts/bin/opt gvn.ll -basicaa -aa-eval -debug-aa
-count-aa -print-all-alias-modref-info -debug -disable-output
// ...
(lldb)
Process 3397 stopped
* thread #1: tid = 0xcebe7, 0x00000001016e3ce3 opt`(anonymous
namespace)::BasicAliasAnalysis::aliasGEP(this=0x0000000104809000,
GEP1=0x000000010410ab30, V1Size=8, V1AAInfo=0x00007fff5fbfce60,
V2=0x000000010410a860, V2Size=8, V2AAInfo=0x00007fff5fbfce78,
UnderlyingV1=0x0000000104109e68, UnderlyingV2=0x0000000104109e68) + 3651 at
BasicAliasAnalysis.cpp:1101, queue = 'com.apple.main-thread', stop reason =
step over
frame #0: 0x00000001016e3ce3 opt`(anonymous
namespace)::BasicAliasAnalysis::aliasGEP(this=0x0000000104809000,
GEP1=0x000000010410ab30, V1Size=8, V1AAInfo=0x00007fff5fbfce60,
V2=0x000000010410a860, V2Size=8, V2AAInfo=0x00007fff5fbfce78,
UnderlyingV1=0x0000000104109e68, UnderlyingV2=0x0000000104109e68) + 3651 at
BasicAliasAnalysis.cpp:1101
1098 uint64_t ModOffset = (uint64_t)GEP1BaseOffset & (Modulo - 1);
1099 if (V1Size != UnknownSize && V2Size != UnknownSize &&
1100 ModOffset >= V2Size && V1Size <= Modulo - ModOffset)
-> 1101 return NoAlias;
1102
1103 // If we know all the variables are positive, then GEP1 >=
GEP1BasePtr.
1104 // If GEP1BasePtr > V2 (GEP1BaseOffset > 0) then we know the
pointers
(lldb) p V1Size
(uint64_t) $20 = 8
(lldb) p V2Size
(uint64_t) $21 = 8
(lldb) p ModOffset
(uint64_t) $22 = 8
(lldb) p Modulo
(uint64_t) $23 = 16
(lldb) p GEP1->getName()
(llvm::StringRef) $24 = (Data = "y", Length = 1)
(lldb) p V2->getName()
(llvm::StringRef) $25 = (Data = "x", Length = 1)
(lldb) p GEP1BaseOffset
(int64_t) $26 = 8
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141020/4d85d5f6/attachment.html>
More information about the llvm-commits
mailing list