Repository navigation
fold shifts through constant or - #145
Open
can-lehmann wants to merge 2 commits into
Open
can-lehmann wants to merge 2 commits into
can-lehmann wants to merge 2 commits into
Conversation
Coverage
Diff CoverageDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
jitir.hppLines 4310-4318 4310 uint64_t combined = inner_constant->value() | constant->value();
4311 if (combined == inner_constant->value()) {
4312 return inner;
4313 }
! 4314 return fold_or(inner->arg(0), build_const(a->type(), combined));
4315 }
4316 }
4317 } else if (dynmatch(AndInst, and_a, a)) {
4318 if (dynmatch(AndInst, and_b, b)) {Lines 8026-8037 8026 if ((used.used & b->value()) == 0) {
8027 return or_inst->arg(0);
8028 }
8029 if (dynmatch(OrInst, inner, or_inst->arg(0))) {
! 8030 if (dynamic_cast<Const*>(inner->arg(1))) {
! 8031 return _builder.fold_or(inner, b);
! 8032 }
! 8033 }
8034 }
8035 } else if (dynmatch(ShlInst, shl, inst)) {
8036 if (dynmatch(Const, shift, shl->arg(1))) {
8037 if (shift->value() < type_width(shl->type())) {Lines 8035-8053 8035 } else if (dynmatch(ShlInst, shl, inst)) {
8036 if (dynmatch(Const, shift, shl->arg(1))) {
8037 if (shift->value() < type_width(shl->type())) {
8038 if (dynmatch(OrInst, inner, shl->arg(0))) {
! 8039 if (inner->name() < section->name_count() && uses.at(inner).size() == 1 &&
! 8040 uses.at(inner).front().inst == shl) {
! 8041 for (size_t index = 0; index < 2; index++) {
! 8042 if (dynmatch(Const, constant, inner->arg(index))) {
! 8043 uint64_t shifted = (constant->value() << shift->value()) & type_mask(shl->type());
! 8044 return _builder.fold_or(_builder.fold_shl(inner->arg(1 - index), shift),
! 8045 _builder.build_const(shl->type(), shifted));
! 8046 }
! 8047 }
! 8048 }
! 8049 }
8050 }
8051 }
8052 } else if (dynamic_cast<ResizeUInst*>(inst) ||
8053 dynamic_cast<ResizeSInst*>(inst)) { |
Coverage
Diff CoverageDiff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
jitir.hppLines 4311-4319 4311 uint64_t combined = inner_constant->value() | constant->value();
Lines 8027-8039 8027 if ((used.used & b->value()) == 0) {
8028 return or_inst->arg(0);
8029 }
8030 if (dynmatch(OrInst, inner, or_inst->arg(0))) {
! 8031 if (dynamic_cast<Const*>(inner->arg(1))) {
8032 // (x | c1) | c2 => x | (c1 | c2)
! 8033 return _builder.fold_or(inner, b);
! 8034 }
! 8035 }
8036 }
8037 } else if (dynmatch(ShlInst, shl, inst)) {
8038 if (dynmatch(Const, shift, shl->arg(1))) {
8039 if (shift->value() < type_width(shl->type())) {Lines 8037-8056 8037 } else if (dynmatch(ShlInst, shl, inst)) {
8038 if (dynmatch(Const, shift, shl->arg(1))) {
8039 if (shift->value() < type_width(shl->type())) {
8040 if (dynmatch(OrInst, inner, shl->arg(0))) {
! 8041 if (inner->name() < section->name_count() && uses.at(inner).size() == 1 &&
! 8042 uses.at(inner).front().inst == shl) {
! 8043 for (size_t index = 0; index < 2; index++) {
! 8044 if (dynmatch(Const, constant, inner->arg(index))) {
8045 // (x | c) << k => (x << k) | ((c << k) & type_mask), for single-use OR and k < width
! 8046 uint64_t shifted = (constant->value() << shift->value()) & type_mask(shl->type());
! 8047 return _builder.fold_or(_builder.fold_shl(inner->arg(1 - index), shift),
! 8048 _builder.build_const(shl->type(), shifted));
! 8049 }
! 8050 }
! 8051 }
! 8052 }
8053 }
8054 }
8055 } else if (dynamic_cast<ResizeUInst*>(inst) ||
8056 dynamic_cast<ResizeSInst*>(inst)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.