1 ; RUN: opt -codegenprepare < %s -S | FileCheck %s
3 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
4 target triple = "aarch64--linux-gnu"
6 %struct.match_state = type { i64, i64 }
8 ; %add is also promoted by forking an extra sext.
9 define void @promoteTwoOne(i32 %i, i32 %j, i64* %P1, i64* %P2 ) {
10 ; CHECK-LABEL: @promoteTwoOne
12 ; CHECK: %[[SEXT1:.*]] = sext i32 %i to i64
13 ; CHECK: %[[SEXT2:.*]] = sext i32 %j to i64
14 ; CHECK: %add = add nsw i64 %[[SEXT1]], %[[SEXT2]]
16 %add = add nsw i32 %i, %j
17 %s = sext i32 %add to i64
18 %addr1 = getelementptr inbounds i64, i64* %P1, i64 %s
19 store i64 %s, i64* %addr1
20 %s2 = sext i32 %i to i64
21 %addr2 = getelementptr inbounds i64, i64* %P2, i64 %s2
22 store i64 %s2, i64* %addr2
26 ; Both %add1 and %add2 are promoted by forking extra sexts.
27 define void @promoteTwoTwo(i32 %i, i32 %j, i32 %k, i64* %P1, i64* %P2) {
28 ; CHECK-LABEL: @promoteTwoTwo
30 ; CHECK: %[[SEXT1:.*]] = sext i32 %j to i64
31 ; CHECK: %[[SEXT2:.*]] = sext i32 %i to i64
32 ; CHECK: %add1 = add nsw i64 %[[SEXT1]], %[[SEXT2]]
33 ; CHECK: %[[SEXT3:.*]] = sext i32 %k to i64
34 ; CHECK: %add2 = add nsw i64 %[[SEXT1]], %[[SEXT3]]
36 %add1 = add nsw i32 %j, %i
37 %s = sext i32 %add1 to i64
38 %addr1 = getelementptr inbounds i64, i64* %P1, i64 %s
39 store i64 %s, i64* %addr1
40 %add2 = add nsw i32 %j, %k
41 %s2 = sext i32 %add2 to i64
42 %addr2 = getelementptr inbounds i64, i64* %P2, i64 %s2
43 store i64 %s2, i64* %addr2
47 define i64 @promoteGEPSunk(i1 %cond, i64* %base, i32 %i) {
48 ; CHECK-LABEL: @promoteGEPSunk
50 ; CHECK: %[[SEXT:.*]] = sext i32 %i to i64
51 ; CHECK: %add = add nsw i64 %[[SEXT]], 1
52 ; CHECK: %add2 = add nsw i64 %[[SEXT]], 2
54 %add = add nsw i32 %i, 1
55 %s = sext i32 %add to i64
56 %addr = getelementptr inbounds i64, i64* %base, i64 %s
57 %add2 = add nsw i32 %i, 2
58 %s2 = sext i32 %add2 to i64
59 %addr2 = getelementptr inbounds i64, i64* %base, i64 %s2
60 br i1 %cond, label %if.then, label %if.then2
62 %v = load i64, i64* %addr
63 %v2 = load i64, i64* %addr2