[PATCH] D153004: [LSR] Consider post-inc form when creating extends/truncates.
Peixin Qiao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 20:46:01 PDT 2023
peixin added a comment.
There may be one more case which this patch does not capture? Check the following input:
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"
@c = internal global i32 0, align 4
@g = dso_local local_unnamed_addr global ptr @c, align 8
@h = dso_local global i8 0, align 4
@j = dso_local local_unnamed_addr global ptr @h, align 8
@b = internal unnamed_addr global i32 0, align 4
@e = dso_local local_unnamed_addr global i16 0, align 4
@f = dso_local local_unnamed_addr global i64 0, align 8
@l = dso_local local_unnamed_addr global i64 0, align 8
@i = dso_local local_unnamed_addr global i64 0, align 8
@.str = private unnamed_addr constant [5 x i8] c"%lX\0A\00", align 1
@a = dso_local local_unnamed_addr global i8 0, align 1
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
define dso_local void @n(ptr nocapture noundef %0) {
ret void
}
; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() {
%1 = load ptr, ptr @g, align 8
%2 = load i64, ptr @f, align 8
br label %3
3: ; preds = %0, %18
%4 = phi i32 [ 0, %0 ], [ %19, %18 ]
%5 = phi i64 [ %2, %0 ], [ %15, %18 ]
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 1, %3 ], [ %10, %6 ]
%8 = phi i64 [ %5, %3 ], [ %9, %6 ]
%9 = add nsw i64 %8, 1
%10 = add nsw i32 %7, -1
%11 = icmp sgt i32 %7, 0
br i1 %11, label %6, label %12
12: ; preds = %6, %12
%13 = phi i32 [ %16, %12 ], [ 1, %6 ]
%14 = phi i64 [ %15, %12 ], [ %9, %6 ]
%15 = add nsw i64 %14, 1
%16 = add nsw i32 %13, -1
%17 = icmp sgt i32 %13, 0
br i1 %17, label %12, label %18
18: ; preds = %12
%19 = add nuw nsw i32 %4, 1
%20 = icmp eq i32 %19, 8
br i1 %20, label %21, label %3
21: ; preds = %18
store i32 %16, ptr @b, align 4
store i32 0, ptr %1, align 4
%22 = zext i32 %13 to i64
store i16 -1, ptr @e, align 4
store i64 %15, ptr @f, align 8
store i64 %14, ptr @l, align 8
store i64 %22, ptr @i, align 8
%23 = urem i32 %16, 53
%24 = trunc i32 %23 to i8
%25 = load ptr, ptr @j, align 8
store i8 %24, ptr %25, align 1
%26 = load i8, ptr @h, align 4
%27 = xor i8 %26, 5
%28 = zext i8 %27 to i64
%29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull @.str, i64 noundef %28)
ret i32 0
}
declare noundef i32 @printf(ptr nocapture noundef readonly, ...)
$ opt -loop-reduce reduced.ll -S -o out.ll && clang out.ll -o a.out && ./a.out
B
$ clang reduced.ll -o a.out && ./a.out
2C
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153004/new/
https://reviews.llvm.org/D153004
More information about the llvm-commits
mailing list