| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Reduce unnecessary guards whenever `len()` is called and used in arithmetic operations.
There was a problem hiding this comment.
Thanks!
Sorry, something went wrong.
|
Windows JIT builds might've been broken by #132852. That PR did not trigger JIT CI. |
Sorry, something went wrong.
| a = [1, 2, 3, 4] | ||
| for _ in range(n): | ||
| _ = len(a) - 1 | ||
|
|
||
| _, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD) |
There was a problem hiding this comment.
I don't know if it's needed in this case, but for other tests there's normally a 'control' variable that checks that the result is still correct even with the optimization. Something like this:
| a = [1, 2, 3, 4] | |
| for _ in range(n): | |
| _ = len(a) - 1 | |
| _, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD) | |
| x = 0 | |
| a = [1, 2, 3, 4] | |
| for _ in range(n): | |
| _ = len(a) - 1 | |
| if _ == 3: | |
| x += 1 | |
| _, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD) | |
| self.assertEqual(res, TIER2_THRESHOLD) |
Sorry, something went wrong.
There was a problem hiding this comment.
Good point, I'll do it.
Sorry, something went wrong.
There was a problem hiding this comment.
OK the problem is if I add this, _GUARD_TOS_INT and _GUARD_NOS_INT are appearing in the uops list.
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah we can't do it. x is from outside the loop (trace), so the first x += 1 has to have a guard somewhere.
Sorry, something went wrong.
…e-131798.NpcKub.rst Co-authored-by: Max Bernstein <tekknolagi@gmail.com>
| Back | FazBrowse Home | New Git URL |
Reduce unnecessary guards whenever len() is called and used in arithmetic operations.