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] Simplify modulo POT (Stage 1) #2352

Merged
merged 2 commits into from May 19, 2021
Merged

Conversation

xumingkuan
Copy link
Collaborator

Related issue = #944

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_sar $2 $3
    <u32> $5 = bit_shl $4 $3
    <u32> $6 = sub $2 $5
    <i32> $7 = cmp_eq $6 $3
    <i32> $8 = bit_and $7 $1
    $9 : if $8 {
      print $2, "\n"
    }

After:

    <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"
    }

[Click here for the format server]


@xumingkuan xumingkuan requested a review from k-ye May 19, 2021 06:55
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.

Great LGTM!

@xumingkuan xumingkuan merged commit 1db6d55 into taichi-dev:master May 19, 2021
@xumingkuan xumingkuan deleted the binary branch May 19, 2021 08:50
@xumingkuan xumingkuan mentioned this pull request May 20, 2021
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