continue
}
- header := ind.Block
- check := header.Controls[0]
- if check == nil {
- // we don't know how to rewrite a loop that not simple comparison
- continue
- }
- switch check.Op {
- case OpLeq64, OpLeq32, OpLeq16, OpLeq8,
- OpLess64, OpLess32, OpLess16, OpLess8:
- default:
- // we don't know how to rewrite a loop that not simple comparison
- continue
- }
- if !((check.Args[0] == ind && check.Args[1] == end) ||
- (check.Args[1] == ind && check.Args[0] == end)) {
- // we don't know how to rewrite a loop that not simple comparison
- continue
- }
if end.Block == ind.Block {
// we can't rewrite loops where the condition depends on the loop body
// this simple check is forced to work because if this is true a Phi in ind.Block must exists
continue
}
+ check := ind.Block.Controls[0]
// invert the check
check.Args[0], check.Args[1] = check.Args[1], check.Args[0]
- // invert start and end in the loop
+ // swap start and end in the loop
for i, v := range check.Args {
if v != end {
continue