Comments (3)
Thank you @nunoplopes for your response! What puzzles me is that
@llvm.uadd.with.overflow
will be converted to theadd
+ult
during legalization phase (LLVM common code is responsible for this), so does that mean we can get the same problem withundef
like here?
No one said that LLVM was correct 🙂
Legalization at the end of the pipeline, so in practice it may not matter since assembly doesn't have undef. SDAG does have undef & poison, so I'm not saying everything is great, but the chances of miscompilations is low.
That's not true if done in the middle of the optimization pipeline. But these days. clang adds noundef to most (all?) function arguments, so it's relatively easy to ensure something isn't undef. You can also use freeze
.
from alive2.
I'm sorry to say but the optimization is indeed incorrect when %arg1
is undef. You can see that Alive2 proves it correct if you add noundef
to the first argument.
This is because @llvm.uadd.with.overflow
does the addition and overflow check with the same value, while if you lower it into add+icmp, each operation may observe different values for %arg1m
(undef can yield a different value each time it is used).
Take the counterexample, where %modulo = #x3
.
Then %arg1m
and %arg2m
must be in [0,2]
and so their sum never overflows. So %obit
in src is always false.
On the other hand, in tgt, icmp ult %sum, %arg1m
can yield true or false depending on the inputs. Then branching on a non-deterministic value is UB.
I know the counterexample isn't too easy to read. But the optimization is incorrect.
from alive2.
Thank you @nunoplopes for your response!
What puzzles me is that @llvm.uadd.with.overflow
will be converted to the add
+ ult
during legalization phase (LLVM common code is responsible for this), so does that mean we can get the same problem with undef
like here?
from alive2.
Related Issues (20)
- missed alarm? HOT 2
- add support for range attribute in args and ret val
- Unknown command line argument '-tv' HOT 7
- Add support for poison-generating flags `nuw`/`nsw` to `trunc`
- False positive and different refined value of `zext undef` HOT 3
- Errors about unsupported instruction `invoke` HOT 4
- Load widening for higher aligned pointer incorrectly reported as undefined HOT 2
- byval arg & memory(argmem) don't work together
- Consider the new 2-phase memory model HOT 2
- Add support for pointers larger than 64 bits HOT 5
- Add support for gep's nuw nusw attributes HOT 2
- bug relating to too-big store? HOT 1
- Add a flag to disable counterexamples with type punning through memory HOT 1
- Issue that cannot see SMT query. HOT 12
- False negative with the sign bit of nans HOT 1
- Incorrect handling of poison values HOT 1
- Incorrect handling of undef values HOT 1
- LLVM version HOT 1
- Is this a false positive? HOT 1
- `ERROR: program doesn't type check!` is raised when the intrinsic call has both noundef and range metadata.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alive2.