-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[InstCombine] Decompose constant xor operand if possible #147599
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
base: main
Are you sure you want to change the base?
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,31 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: opt -mtriple=amdgcn-amd-amdhsa -passes=instcombine \ | ||
; RUN: -S < %s | FileCheck %s | ||
|
||
define half @xor_to_or_disjoint(i1 %0, ptr %ptr) { | ||
; CHECK-LABEL: define half @xor_to_or_disjoint( | ||
; CHECK-SAME: i1 [[TMP0:%.*]], ptr [[PTR:%.*]]) { | ||
; CHECK-NEXT: [[ENTRY:.*:]] | ||
; CHECK-NEXT: [[ADDR1:%.*]] = select i1 [[TMP0]], i64 32, i64 256 | ||
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i8, ptr [[PTR]], i64 [[ADDR1]] | ||
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr i8, ptr [[PTR]], i64 [[ADDR1]] | ||
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i8, ptr [[TMP1]], i64 2048 | ||
; CHECK-NEXT: [[VAL1:%.*]] = load half, ptr [[GEP1]], align 2 | ||
; CHECK-NEXT: [[VAL2:%.*]] = load half, ptr [[GEP2]], align 2 | ||
; CHECK-NEXT: [[RESULT_H:%.*]] = fadd half [[VAL1]], [[VAL2]] | ||
; CHECK-NEXT: ret half [[RESULT_H]] | ||
; | ||
entry: | ||
%base = select i1 %0, i64 0, i64 288 | ||
%addr1 = xor i64 %base, 32 | ||
%addr2 = xor i64 %base, 2080 | ||
%gep1 = getelementptr i8, ptr %ptr, i64 %addr1 | ||
%gep2 = getelementptr i8, ptr %ptr, i64 %addr2 | ||
%val1 = load half, ptr %gep1 | ||
%val2 = load half, ptr %gep2 | ||
%val1.f = fpext half %val1 to float | ||
%val2.f = fpext half %val2 to float | ||
%sum1.f = fadd float %val1.f, %val2.f | ||
%result.h = fptrunc float %sum1.f to half | ||
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. This test contains a lot of unrelated instructions. |
||
ret half %result.h | ||
} | ||
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. This transform needs more tests to exercise the pre-conditions of the transform, e.g. the disjointness. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Triple shouldn't be necessary.