Skip to content

Conversation

terapines-osc-cir
Copy link
Contributor

@terapines-osc-cir terapines-osc-cir commented Oct 9, 2025

The PR1735 contains too many conflicts with the main branch.

Got it re-patched to the current main branch.

This only deals with the case in which the break is directly under the loop, not nested in any ifs.
In this case we simply erase the loop as well as unreachable code after that break.

// CHECK: memref.alloca_scope {
// CHECK: %[[IV:.+]] = memref.load %alloca[]
// CHECK: %[[HUNDRED:.+]] = arith.constant 100
// CHECK: %[[_:.+]] = arith.cmpi slt, %[[IV]], %[[HUNDRED]]
Copy link
Member

Choose a reason for hiding this comment

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

I was looking at the generated IR and I'm not sure this works right, the loop is gone but you still need to increment i, what am I missing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the 2nd i++ (operations after break) that got removed, the 1st i++ is kept.

  while (i < 100) {
    i++;
    break;
    i++;
  }

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