mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-06 02:47:20 +00:00
2666864c81
Summary: Move the aarch64-type-promotion pass within the existing type promotion framework in CGP. This change also support forking sexts when a new sext is required for promotion. Note that change is based on D27853 and I am submitting this out early to provide a better idea on D27853. Reviewers: jmolloy, mcrosier, javed.absar, qcolombet Reviewed By: qcolombet Subscribers: llvm-commits, aemerson, rengolin, mcrosier Differential Revision: https://reviews.llvm.org/D28680 llvm-svn: 299379
69 lines
2.1 KiB
LLVM
69 lines
2.1 KiB
LLVM
; RUN: opt -codegenprepare < %s -S | FileCheck %s
|
|
|
|
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
|
target triple = "aarch64--linux-gnu"
|
|
|
|
%struct.match_state = type { i64, i64 }
|
|
|
|
; %add is also promoted by forking an extra sext.
|
|
define void @promoteTwoOne(i32 %i, i32 %j, i64* %P1, i64* %P2 ) {
|
|
; CHECK-LABEL: @promoteTwoOne
|
|
; CHECK-LABEL: entry:
|
|
; CHECK: %[[SEXT1:.*]] = sext i32 %i to i64
|
|
; CHECK: %[[SEXT2:.*]] = sext i32 %j to i64
|
|
; CHECK: %add = add nsw i64 %[[SEXT1]], %[[SEXT2]]
|
|
entry:
|
|
%add = add nsw i32 %i, %j
|
|
%s = sext i32 %add to i64
|
|
%addr1 = getelementptr inbounds i64, i64* %P1, i64 %s
|
|
store i64 %s, i64* %addr1
|
|
%s2 = sext i32 %i to i64
|
|
%addr2 = getelementptr inbounds i64, i64* %P2, i64 %s2
|
|
store i64 %s2, i64* %addr2
|
|
ret void
|
|
}
|
|
|
|
; Both %add1 and %add2 are promoted by forking extra sexts.
|
|
define void @promoteTwoTwo(i32 %i, i32 %j, i32 %k, i64* %P1, i64* %P2) {
|
|
; CHECK-LABEL: @promoteTwoTwo
|
|
; CHECK-LABEL:entry:
|
|
; CHECK: %[[SEXT1:.*]] = sext i32 %j to i64
|
|
; CHECK: %[[SEXT2:.*]] = sext i32 %i to i64
|
|
; CHECK: %add1 = add nsw i64 %[[SEXT1]], %[[SEXT2]]
|
|
; CHECK: %[[SEXT3:.*]] = sext i32 %k to i64
|
|
; CHECK: %add2 = add nsw i64 %[[SEXT1]], %[[SEXT3]]
|
|
entry:
|
|
%add1 = add nsw i32 %j, %i
|
|
%s = sext i32 %add1 to i64
|
|
%addr1 = getelementptr inbounds i64, i64* %P1, i64 %s
|
|
store i64 %s, i64* %addr1
|
|
%add2 = add nsw i32 %j, %k
|
|
%s2 = sext i32 %add2 to i64
|
|
%addr2 = getelementptr inbounds i64, i64* %P2, i64 %s2
|
|
store i64 %s2, i64* %addr2
|
|
ret void
|
|
}
|
|
|
|
define i64 @promoteGEPSunk(i1 %cond, i64* %base, i32 %i) {
|
|
; CHECK-LABEL: @promoteGEPSunk
|
|
; CHECK-LABEL: entry:
|
|
; CHECK: %[[SEXT:.*]] = sext i32 %i to i64
|
|
; CHECK: %add = add nsw i64 %[[SEXT]], 1
|
|
; CHECK: %add2 = add nsw i64 %[[SEXT]], 2
|
|
entry:
|
|
%add = add nsw i32 %i, 1
|
|
%s = sext i32 %add to i64
|
|
%addr = getelementptr inbounds i64, i64* %base, i64 %s
|
|
%add2 = add nsw i32 %i, 2
|
|
%s2 = sext i32 %add2 to i64
|
|
%addr2 = getelementptr inbounds i64, i64* %base, i64 %s2
|
|
br i1 %cond, label %if.then, label %if.then2
|
|
if.then:
|
|
%v = load i64, i64* %addr
|
|
%v2 = load i64, i64* %addr2
|
|
%r = add i64 %v, %v2
|
|
ret i64 %r
|
|
if.then2:
|
|
ret i64 0;
|
|
}
|