Skip to content

[CIR][Lowering] add cir.ternary to scf.if lowering #368

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

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

Kuree
Copy link
Contributor

@Kuree Kuree commented Dec 28, 2023

This PR adds cir.ternary lowering. There are two approaches to lower cir.ternary imo:

  1. Use scf.if op.
  2. Use cf.cond_br op.

I choose scf.if because scf.if + canonicalization produces arith.select whereas cf.cond_br requires scf lifting. In many ways scf.if is more high-level and closer to cir.ternary.

A separate cir.yield lowering is required since we cannot directly replace cir.yield in the ternary op lowering -- the yield operands may still be illegal and doing so produces builtin.unrealized_cast ops. I couldn't figured out a way to solve this issue without adding a separate lowering pattern. Please let me know if you know a way to solve this issue.

@bcardosolopes
Copy link
Member

the yield operands may still be illegal and doing so produces builtin.unrealized_cast ops. I couldn't figured out a way to solve this issue without adding a separate lowering pattern

There's really no way around this I'm aware of - it's totally fine!

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bcardosolopes bcardosolopes merged commit 0562ffc into llvm:main Jan 4, 2024
lanza pushed a commit that referenced this pull request Jan 29, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op. 

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
lanza pushed a commit that referenced this pull request Mar 23, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op. 

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Mar 24, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op. 

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Mar 24, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op. 

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
lanza pushed a commit that referenced this pull request Apr 29, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op. 

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
lanza pushed a commit that referenced this pull request Apr 29, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op. 

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Apr 29, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op. 

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
lanza pushed a commit that referenced this pull request Apr 29, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op.

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
bruteforceboy pushed a commit to bruteforceboy/clangir that referenced this pull request Oct 2, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op.

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op.

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op.

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
lanza pushed a commit that referenced this pull request Nov 5, 2024
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op.

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
lanza pushed a commit that referenced this pull request Mar 18, 2025
This PR adds `cir.ternary` lowering. There are two approaches to lower
`cir.ternary` imo:
1. Use `scf.if` op.
2. Use `cf.cond_br` op.

I choose `scf.if` because `scf.if` + canonicalization produces
`arith.select` whereas `cf.cond_br` requires scf lifting. In many ways
`scf.if` is more high-level and closer to `cir.ternary`.

A separate `cir.yield` lowering is required since we cannot directly
replace `cir.yield` in the ternary op lowering -- the yield operands may
still be illegal and doing so produces `builtin.unrealized_cast` ops. I
couldn't figured out a way to solve this issue without adding a separate
lowering pattern. Please let me know if you know a way to solve this
issue.
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.

2 participants