Skip to content
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

[opt] [bug] Simplify modulo POT (Stage 2) #2411

Merged
merged 4 commits into from
Jun 9, 2021
Merged

Conversation

xumingkuan
Copy link
Collaborator

Related issue = #944
A continuation of #2352 and fixes a bug introduced in that PR.

Test case:

import taichi as ti

ti.init(print_ir=True)


@ti.kernel
def func(i: ti.u32):
    if i % 2 == 1:
        print(i)


func(1)

Before:

    <i32> $1 = const [1]
    <u32> $2 = arg[0]
    <u32> $3 = const [1]
    <u32> $4 = bit_and $2 $3
    <u32> $5 = sub $2 $4
    <i32> $6 = cmp_eq $5 $3
    <i32> $7 = bit_and $6 $1
    $8 : if $7 {
      print $2, "\n"
    }

After:

    <i32> $1 = const [1]
    <u32> $2 = arg[0]
    <u32> $3 = const [1]
    <u32> $4 = bit_and $2 $3
    <i32> $5 = cmp_eq $4 $3
    <i32> $6 = bit_and $5 $1
    $7 : if $6 {
      print $2, "\n"
    }

[Click here for the format server]


@xumingkuan xumingkuan requested a review from k-ye June 8, 2021 06:45
Copy link
Member

@k-ye k-ye left a comment

Choose a reason for hiding this comment

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

Please add the test if there was a bug, thx!

taichi/transforms/binary_op_simplify.cpp Outdated Show resolved Hide resolved
xumingkuan and others added 3 commits June 8, 2021 16:19
Co-authored-by: Ye Kuang <k-ye@users.noreply.github.com>
@xumingkuan xumingkuan requested a review from k-ye June 8, 2021 08:22
Copy link
Member

@k-ye k-ye left a comment

Choose a reason for hiding this comment

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

Thanks LGTM!

@k-ye k-ye merged commit 7a79003 into taichi-dev:master Jun 9, 2021
@k-ye k-ye mentioned this pull request Jun 21, 2021
@xumingkuan xumingkuan deleted the pot2 branch June 29, 2021 06:02
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.

None yet

2 participants