Skip to content

SSA Transform useless phis on exit block #20

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
dibyendumajumdar opened this issue Jan 1, 2025 · 0 comments
Open

SSA Transform useless phis on exit block #20

dibyendumajumdar opened this issue Jan 1, 2025 · 0 comments
Labels
fixed Fixed

Comments

@dibyendumajumdar
Copy link
Contributor

This test case:

func foo(x: Int, y: Int)->Int {
   var sum: Int
   
   if (x >= y)
      return 0
      
   sum = 0;
   while (x < y) {
      if (x / 2 * 2 == x) {
         sum = sum + 1
      }
      x = x + 1
   }
   return sum
}

Generates:

After SSA
=========
L0:
    arg x_0
    arg y_0
    %t3_0 = x_0>=y_0
    if %t3_0 goto L2 else goto L3
L2:
    ret 0
    goto  L1
L1:
    sum_4 = phi(sum_1, sum_1)
    x_3 = phi(x_1, x_1)
L3:
    sum_0 = 0
    goto  L4
L4:
    sum_1 = phi(sum_0, sum_3)
    x_1 = phi(x_0, x_2)
    %t4_0 = x_1<y_0
    if %t4_0 goto L5 else goto L6
L5:
    %t5_0 = x_1/2
    %t6_0 = %t5_0*2
    %t7_0 = %t6_0==x_1
    if %t7_0 goto L7 else goto L8
L7:
    %t8_0 = sum_1+1
    sum_2 = %t8_0
    goto  L8
L8:
    sum_3 = phi(sum_1, sum_2)
    %t9_0 = x_1+1
    x_2 = %t9_0
    goto  L4
L6:
    ret sum_1
    goto  L1

dibyendumajumdar added a commit that referenced this issue Jan 1, 2025
@dibyendumajumdar dibyendumajumdar added the fixed Fixed label Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Fixed
Projects
None yet
Development

No branches or pull requests

1 participant