Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by davikrr on Thursday August 19, 2021 @09:34AM
(#28233630)
"LLVM considers infinite recursion to be UB, so the only valid way for this function to execute is to return true"
[ Parent
| on HN ]
Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by jasode on Thursday August 19, 2021 @10:06AM
(#28233989)
>"LLVM considers infinite recursion to be UB,
Not sure why he used the word "recursion" since collatz() is not calling itself.
Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by forgetfulness on Thursday August 19, 2021 @11:23AM
(#28235016)
It's in the computability theory sense, since compilers and language specifications are symbolic math-heavy, and in math you model all these things as recursive functions, the terminology is applied uniformly.
Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by tpush on Thursday August 19, 2021 @10:29AM
(#28234259)
He means the general concept of recursion, of which looping is an implementation, so to speak.
Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by Winsaucerer on Thursday August 19, 2021 @09:50AM
(#28233798)
What does 'UB' stand for?
Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by loeg on Thursday August 19, 2021 @09:56AM
(#28233866)
Undefined Behavior.
Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by the_only_law on Thursday August 19, 2021 @09:51AM
(#28233808)
Undefined Behavior
Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by tomhallett on Thursday August 19, 2021 @11:14AM
(#28234892)
How does LLVM decide this loop is unbounded? Is any `while(true)` loop considered UB and therefore replaced with `return true` or is there more advanced introspection of the ast (some limited set of the halting problem)?
Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by detaro on Thursday August 19, 2021 @12:15PM
(#28235700)
It checks how the loop can be exited, assumes that the loop must exit and thus take the code path that exits it, and then applies optimizations to remove everything it doesn't need to find the result.
Re:“Pack it in, mathematicians, someone owes LLVM a million ...
by andrewaylett on Thursday August 19, 2021 @11:41AM
(#28235252)
Which isn't quite right: the C++ spec allows the compiler to assume that a loop without side-effects will terminate. And the only way the loop terminates will be by returning true.