You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
903 B

/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/* t is also in control variables but once we have invariant analysis, it
* shouldn't be */
int break_loop(int p, int t) {
for (int i = 0; i < p; i++) {
// do something
if (t < 0)
break;
// do something
}
return 0;
}
/* t will be in control variables but once we have invariant analysis,
* it shouldn't be. */
int break_loop_with_t(int p, int t) {
for (int i = 0; i < p; i++) {
// do something
if (t < 0) {
t++;
break;
}
// do something
}
return 0;
}
/* calling break_loop with a negative t should give constant
cost. Currently, this doesn't work since we can't do case analysis
on the domain. */
int break_constant(int p) { return break_loop(p, -1); }