Skip to content

Drop if #1

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

Open
wants to merge 2 commits into
base: drop-elab
Choose a base branch
from
Open

Drop if #1

wants to merge 2 commits into from

Conversation

zeegomo
Copy link
Owner

@zeegomo zeegomo commented Dec 15, 2022

This is a conservative approach to the introduction of DropIf.
In some cases, we still resort to drop flags and branches in the CFG.
Those do not break the promises we make about DropIf but makes it less effective
At the moment these include:

  • drop loops for arrays
  • multivariant enums

We also need to de-elaborate drops for async generators. For reasons that are still not clear to me, we run drop elaboration twice on those, which was previously possible but now isn't since domain and codomain of the drop elaboration 'function' are now different (dropifinit -> dropif)

@zeegomo zeegomo force-pushed the drop-if branch 3 times, most recently from 798fee2 to afdec3c Compare December 16, 2022 19:48
@zeegomo zeegomo force-pushed the drop-elab branch 3 times, most recently from 2303e04 to 54adf94 Compare January 5, 2023 09:35
@zeegomo zeegomo force-pushed the drop-elab branch 2 times, most recently from 67da872 to 25cf2b6 Compare January 10, 2023 17:04
zeegomo pushed a commit that referenced this pull request Feb 4, 2023
…u-se

Implement `SpecOptionPartialEq` for `cmp::Ordering`

Noticed as I continue to explore options for having code using `partial_cmp` optimize better.

Before:
```llvm
; Function Attrs: mustprogress nofree nosync nounwind willreturn uwtable
define noundef zeroext i1 `@ordering_eq(i8` noundef %0, i8 noundef %1) unnamed_addr #0 {
start:
  %2 = icmp eq i8 %0, 2
  br i1 %2, label %bb1.i, label %bb3.i

bb1.i:                                            ; preds = %start
  %3 = icmp eq i8 %1, 2
  br label %"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit"

bb3.i:                                            ; preds = %start
  %.not.i = icmp ne i8 %1, 2
  %4 = icmp eq i8 %0, %1
  %spec.select.i = and i1 %.not.i, %4
  br label %"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit"

"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit": ; preds = %bb1.i, %bb3.i
  %.0.i = phi i1 [ %3, %bb1.i ], [ %spec.select.i, %bb3.i ]
  ret i1 %.0.i
}
```

After:
```llvm
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
define noundef zeroext i1 `@ordering_eq(i8` noundef %0, i8 noundef %1) unnamed_addr #1 {
start:
  %2 = icmp eq i8 %0, %1
  ret i1 %2
}
```

(Which <https://alive2.llvm.org/ce/z/-rop5r> says LLVM *could* just do itself, but there's probably an issue already open for that problem from when this was originally looked at for `Option<NonZeroU8>` and friends.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant