John Regehr via llvm-dev
2016-May-08 20:22 UTC
[llvm-dev] x.with.overflow semantics question
Philip Reames and I are debating the semantics of x.with.overflow and I wanted to see if I could get a ruling here: My read of the langref is that the overflow bit and the result of the operation are independent of each other. In other words, we can count on the result of add.with.overflow being the same as the result of a (non-nsw) add, even in the case where an overflow occurs. Is that right? Thanks! John
Pete Cooper via llvm-dev
2016-May-08 20:31 UTC
[llvm-dev] x.with.overflow semantics question
Hi John That matches my understanding. Otherwise I guess you'd be talking about a saturating operation. Or do you mean that the result of an add may not even be defined? In that case would reading it be considered UB in the case where the overflow bit was set? Cheers Pete Sent from my iPhone> On May 8, 2016, at 1:22 PM, John Regehr via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Philip Reames and I are debating the semantics of x.with.overflow and I wanted to see if I could get a ruling here: > > My read of the langref is that the overflow bit and the result of the operation are independent of each other. In other words, we can count on the result of add.with.overflow being the same as the result of a (non-nsw) add, even in the case where an overflow occurs. Is that right? > > Thanks! > > John > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
John Regehr via llvm-dev
2016-May-08 20:57 UTC
[llvm-dev] x.with.overflow semantics question
Hi Pete, > Or do you mean that the result of an add may not even be defined? In that case would reading it be considered UB in the case where the overflow bit was set? Yeah, this is the case I'm worried about: that for example sadd.with.overflow(INT_MAX, 1) might be designed to return { poison, true } instead of giving a useful result in the first element of the struct. John