-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[PPC] Add custom lowering for uaddo #110137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu | FileCheck %s | ||
syzaara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
; RUN: llc < %s -mtriple=powerpc-ibm-aix-xcoff | FileCheck %s | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these IR not valid for 64bit? I would think we can just have 1 tc and make sure we test for both 32 and 64bit on Linux and AIX. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is valid, but I'm only custom lowering @llvm.uadd.with.overflow.i32 for 32-bit mode and @llvm.uadd.with.overflow.i64 for 64-bit mode. So I didn't add the checks for the other modes as its the default lowering. |
||
define noundef i32 @add(i32 noundef %a, i32 noundef %b, ptr nocapture noundef writeonly %ovf) { | ||
; CHECK-LABEL: add: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: li 6, 0 | ||
; CHECK-NEXT: addc 3, 3, 4 | ||
; CHECK-NEXT: addze 4, 6 | ||
; CHECK-NEXT: stw 4, 0(5) | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b) | ||
%1 = extractvalue { i32, i1 } %0, 1 | ||
%2 = extractvalue { i32, i1 } %0, 0 | ||
%3 = zext i1 %1 to i32 | ||
store i32 %3, ptr %ovf, align 8 | ||
ret i32 %2 | ||
} | ||
|
||
declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) | ||
|
||
define noundef zeroext i1 @add_overflow(i32 noundef %a, i32 noundef %b, ptr nocapture noundef writeonly %ovf) { | ||
; CHECK-LABEL: add_overflow: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: li 6, 0 | ||
; CHECK-NEXT: addc 4, 3, 4 | ||
; CHECK-NEXT: addze 3, 6 | ||
; CHECK-NEXT: stw 4, 0(5) | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b) | ||
%1 = extractvalue { i32, i1 } %0, 1 | ||
%2 = extractvalue { i32, i1 } %0, 0 | ||
store i32 %2, ptr %ovf, align 8 | ||
ret i1 %1 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s | ||
syzaara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
; RUN: llc < %s -mtriple=powerpc64-ibm-aix-xcoff | FileCheck %s | ||
|
||
define noundef i64 @add(i64 noundef %a, i64 noundef %b, ptr nocapture noundef writeonly %ovf) { | ||
; CHECK-LABEL: add: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: li 6, 0 | ||
; CHECK-NEXT: addc 3, 3, 4 | ||
; CHECK-NEXT: addze 4, 6 | ||
; CHECK-NEXT: std 4, 0(5) | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) | ||
%1 = extractvalue { i64, i1 } %0, 1 | ||
%2 = extractvalue { i64, i1 } %0, 0 | ||
%3 = zext i1 %1 to i64 | ||
store i64 %3, ptr %ovf, align 8 | ||
ret i64 %2 | ||
} | ||
|
||
declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) | ||
|
||
define noundef zeroext i1 @add_overflow(i64 noundef %a, i64 noundef %b, ptr nocapture noundef writeonly %ovf) { | ||
; CHECK-LABEL: add_overflow: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: li 6, 0 | ||
; CHECK-NEXT: addc 4, 3, 4 | ||
; CHECK-NEXT: addze 3, 6 | ||
; CHECK-NEXT: std 4, 0(5) | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) | ||
%1 = extractvalue { i64, i1 } %0, 1 | ||
%2 = extractvalue { i64, i1 } %0, 0 | ||
store i64 %2, ptr %ovf, align 8 | ||
ret i1 %1 | ||
} | ||
|
||
define noundef i64 @addWithCarryIn (i64 noundef %a, i64 noundef %b, i64 noundef %c, ptr nocapture noundef writeonly %ovf) { | ||
; CHECK-LABEL: addWithCarryIn: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: li 7, 0 | ||
; CHECK-NEXT: addc 3, 3, 4 | ||
; CHECK-NEXT: addze 4, 7 | ||
; CHECK-NEXT: addc 3, 3, 5 | ||
; CHECK-NEXT: addze 5, 7 | ||
; CHECK-NEXT: or 4, 4, 5 | ||
; CHECK-NEXT: std 4, 0(6) | ||
; CHECK-NEXT: blr | ||
entry: | ||
%0 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) | ||
%1 = extractvalue { i64, i1 } %0, 1 | ||
%2 = extractvalue { i64, i1 } %0, 0 | ||
%3 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %2, i64 %c) | ||
%4 = extractvalue { i64, i1 } %3, 1 | ||
%5 = extractvalue { i64, i1 } %3, 0 | ||
%6 = or i1 %1, %4 | ||
%7 = zext i1 %6 to i64 | ||
store i64 %7, ptr %ovf, align 8 | ||
ret i64 %5 | ||
} |
Uh oh!
There was an error while loading. Please reload this page.