Skip to content
  1. Mar 18, 2016
  2. Mar 17, 2016
    • Tim Shen's avatar
      [PPC, FastISel] Fix ordered/unordered fcmp · 5cdf7508
      Tim Shen authored
      For fcmp, major concern about the following 6 cases is NaN result. The
      comparison result consists of 4 bits, indicating lt, eq, gt and un (unordered),
      only one of which will be set. The result is generated by fcmpu
      instruction. However, bc instruction only inspects one of the first 3
      bits, so when un is set, bc instruction may jump to to an undesired
      place.
      
      More specifically, if we expect an unordered comparison and un is set, we
      expect to always go to true branch; in such case UEQ, UGT and ULT still
      give false, which are undesired; but UNE, UGE, ULE happen to give true,
      since they are tested by inspecting !eq, !lt, !gt, respectively.
      
      Similarly, for ordered comparison, when un is set, we always expect the
      result to be false. In such case OGT, OLT and OEQ is good, since they are
      actually testing GT, LT, and EQ respectively, which are false. OGE, OLE
      and ONE are tested through !lt, !gt and !eq, and these are true.
      
      llvm-svn: 263753
      5cdf7508
    • Lang Hames's avatar
      [Support] Add ExitOnError utility to support tools that use the exit-on-error · 6935c2d3
      Lang Hames authored
      idiom.
      
      Most LLVM tool code exits immediately when an error is encountered and prints an
      error message to stderr. The ExitOnError class supports this by providing two
      call operators - one for Errors, and one for Expected<T>s. Calls to code that
      can return Errors (or Expected<T>s) can use these calls to bail out on error,
      and otherwise continue as if the operation had succeeded. E.g.
      
      Error foo();
      Expected<int> bar();
      
      int main(int argc, char *argv[]) {
        ExitOnError ExitOnErr;
      
        ExitOnErr.setBanner(std::string("Error in ") + argv[0] + ":");
      
        // Exit if foo returns an error. No need to manually check error return.
        ExitOnErr(foo());
      
        // Exit if bar returns an error, otherwise unwrap the contained int and
        // continue.
        int X = ExitOnErr(bar());
      
        // ...
      
        return 0;
      }
      
      llvm-svn: 263749
      6935c2d3
Loading