Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: tests_lit/llvm2ice_tests/addr-opt-multi-def-var.ll

Issue 490333003: Subzero: Fix address mode optimization involving phi temporaries. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review comments 1 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/llvm2ice.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 ; This is distilled from a real function that led to a bug in the
2 ; address mode optimization code. It followed assignment chains
3 ; through non-SSA temporaries created from Phi instruction lowering.
4 ;
5 ; This test depends to some degree on the stability of "--verbose
6 ; addropt" output format.
7
8 ; RUN: %llvm2ice -O2 --verbose addropt %s | FileCheck %s
9
10 declare i32 @_calloc_r(i32, i32, i32)
11
12 define internal i32 @_Balloc(i32 %ptr, i32 %k) {
13 entry:
14 %gep = add i32 %ptr, 76
15 %gep.asptr = inttoptr i32 %gep to i32*
16 %0 = load i32* %gep.asptr, align 1
17 %cmp = icmp eq i32 %0, 0
18 br i1 %cmp, label %if.then, label %if.end5
19
20 if.then: ; preds = %entry
21 %call = tail call i32 @_calloc_r(i32 %ptr, i32 4, i32 33)
22 %gep.asptr2 = inttoptr i32 %gep to i32*
23 store i32 %call, i32* %gep.asptr2, align 1
24 %cmp3 = icmp eq i32 %call, 0
25 br i1 %cmp3, label %return, label %if.end5
26
27 if.end5: ; preds = %if.then, %entry
28 %1 = phi i32 [ %call, %if.then ], [ %0, %entry ]
29 %gep_array = mul i32 %k, 4
30 %gep2 = add i32 %1, %gep_array
31 %gep2.asptr = inttoptr i32 %gep2 to i32*
32 %2 = load i32* %gep2.asptr, align 1
33 ; The above load instruction is a good target for address mode
34 ; optimization. Correct analysis would lead to dump output like:
35 ; Starting computeAddressOpt for instruction:
36 ; [ 15] %__13 = load i32* %gep2.asptr, align 1
37 ; Instruction: [ 14] %gep2.asptr = i32 %gep2
38 ; results in Base=%gep2, Index=<null>, Shift=0, Offset=0
39 ; Instruction: [ 13] %gep2 = add i32 %__9, %gep_array
40 ; results in Base=%__9, Index=%gep_array, Shift=0, Offset=0
41 ; Instruction: [ 18] %__9 = i32 %__9_phi
42 ; results in Base=%__9_phi, Index=%gep_array, Shift=0, Offset=0
43 ; Instruction: [ 12] %gep_array = mul i32 %k, 4
44 ; results in Base=%__9_phi, Index=%k, Shift=2, Offset=0
45 ;
46 ; Incorrect, overly-aggressive analysis would lead to output like:
47 ; Starting computeAddressOpt for instruction:
48 ; [ 15] %__13 = load i32* %gep2.asptr, align 1
49 ; Instruction: [ 14] %gep2.asptr = i32 %gep2
50 ; results in Base=%gep2, Index=<null>, Shift=0, Offset=0
51 ; Instruction: [ 13] %gep2 = add i32 %__9, %gep_array
52 ; results in Base=%__9, Index=%gep_array, Shift=0, Offset=0
53 ; Instruction: [ 18] %__9 = i32 %__9_phi
54 ; results in Base=%__9_phi, Index=%gep_array, Shift=0, Offset=0
55 ; Instruction: [ 19] %__9_phi = i32 %__4
56 ; results in Base=%__4, Index=%gep_array, Shift=0, Offset=0
57 ; Instruction: [ 12] %gep_array = mul i32 %k, 4
58 ; results in Base=%__4, Index=%k, Shift=2, Offset=0
59 ;
60 ; CHECK-NOT: results in Base=%__4,
61 ;
62 ret i32 %2
63
64 return: ; preds = %if.then
65 ret i32 0
66 }
OLDNEW
« no previous file with comments | « src/llvm2ice.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698