1. Sep 09, 2019
    • Craig Topper's avatar
      [X86] Add a hack to combineVSelectWithAllOnesOrZeros to turn selects with two... · 77dd86ee
      Craig Topper authored
      [X86] Add a hack to combineVSelectWithAllOnesOrZeros to turn selects with two zero/undef vector inputs into an all zeroes vector.
      
      If the two zero vectors have undefs in different places they
      won't get combined by simplifySelect.
      
      This fixes a regression from an earlier commit.
      
      llvm-svn: 371351
      77dd86ee
    • Craig Topper's avatar
      [X86] Remove call to getZeroVector from materializeVectorConstant. Add isel... · 9c119012
      Craig Topper authored
      [X86] Remove call to getZeroVector from materializeVectorConstant. Add isel patterns for zero vectors with all types.
      
      The change to avx512-vec-cmp.ll is a regression, but should be
      easy to fix. It occurs because the getZeroVector call was
      canonicalizing both sides to the same node, then SimplifySelect
      was able to simplify it. But since only called getZeroVector
      on some VTs this isn't a robust way to combine this.
      
      The change to vector-shuffle-combining-ssse3.ll is more
      instructions, but removes a constant pool load so its unclear
      if its a regression or not.
      
      llvm-svn: 371350
      9c119012
    • Roman Lebedev's avatar
      [InstSimplify] simplifyUnsignedRangeCheck(): if we know that X != 0, handle more cases (PR43246) · 6e2c5c87
      Roman Lebedev authored
      Summary:
      This is motivated by D67122 sanitizer check enhancement.
      That patch seemingly worsens `-fsanitize=pointer-overflow`
      overhead from 25% to 50%, which strongly implies missing folds.
      
      In this particular case, given
      ```
      char* test(char& base, unsigned long offset) {
        return &base + offset;
      }
      ```
      it will end up producing something like
      https://godbolt.org/z/LK5-iH
      which after optimizations reduces down to roughly
      ```
      define i1 @t0(i8* nonnull %base, i64 %offset) {
        %base_int = ptrtoint i8* %base to i64
        %adjusted = add i64 %base_int, %offset
        %non_null_after_adjustment = icmp ne i64 %adjusted, 0
        %no_overflow_during_adjustment = icmp uge i64 %adjusted, %base_int
        %res = and i1 %non_null_after_adjustment, %no_overflow_during_adjustment
        ret i1 %res
      }
      ```
      Without D67122 there was no `%non_null_after_adjustment`,
      and in this particular case we can get rid of the overhead:
      
      Here we add some offset to a non-null pointer,
      and check that the result does not overflow and is not a null pointer.
      But since the base pointer is already non-null, and we check for overflow,
      that overflow check will already catch the null pointer,
      so the separate null check is redundant and can be dropped.
      
      Alive proofs:
      https://rise4fun.com/Alive/WRzq
      
      There are more patterns of "unsigned-add-with-overflow", they are not handled here,
      but this is the main pattern, that we currently consider canonical,
      so it makes sense to handle it.
      
      https://bugs.llvm.org/show_bug.cgi?id=43246
      
      Reviewers: spatel, nikic, vsk
      
      Reviewed By: spatel
      
      Subscribers: hiraditya, llvm-commits, reames
      
      Tags: #llvm
      
      Differential Revision: https://reviews.llvm.org/D67332
      
      llvm-svn: 371349
      6e2c5c87
    • Sanjay Patel's avatar
      [InstCombine] add tests for icmp with srem operand; NFC · 354a4644
      Sanjay Patel authored
      llvm-svn: 371348
      354a4644
    • Roman Lebedev's avatar
      [X86] X86DAGToDAGISel::combineIncDecVector(): call getSplatBuildVector() manually · 94db67f0
      Roman Lebedev authored
      As reported in post-commit review of r370327,
      there is some case where the code crashes.
      
      As discussed with Craig Topper, the problem is that getConstant()
      internally calls getSplatBuildVector(), so we don't insert
      the constant itself.
      
      If we do that manually we're good.
      
      llvm-svn: 371346
      94db67f0
    • Craig Topper's avatar
      [X86] Use DAG.getConstant instead of getZeroVector in combinePMULDQ. · 97d41b89
      Craig Topper authored
      getZeroVector canonicalizes the type to vXi32, but that's a
      legalization action. We should use the most correct type if
      possible.
      
      llvm-svn: 371345
      97d41b89
    • Craig Topper's avatar
      [DAGCombiner][X86][ARM] Teach visitMULO to fold multiplies with 0 to 0 and no carry. · dac34f52
      Craig Topper authored
      I modified the ARM test to use two inputs instead of 0 so the
      test hopefully still tests what was intended.
      
      llvm-svn: 371344
      dac34f52
    • Craig Topper's avatar
      [X86] Teach materializeVectorConstant to not call getZeroVector/getOnesVector... · 30837abd
      Craig Topper authored
      [X86] Teach materializeVectorConstant to not call getZeroVector/getOnesVector on the types we already have isel patterns for.
      
      llvm-svn: 371343
      30837abd
    • Gabor Borsik's avatar
      Move prop-sink branch to monorepo. · 080ecafd
      Gabor Borsik authored
      llvm-svn: 371342
      080ecafd
    • Sanjay Patel's avatar
      [InstCombine] fold extract+insert into identity shuffle · aff5bee3
      Sanjay Patel authored
      This is similar to the existing fold for splats added with:
      rL365379
      
      If we can adjust the shuffle mask to include another element
      in an identity mask (if it changes vector length, that's an
      extract/insert subvector operation in the backend), then that
      can eliminate extractelement/insertelement pairs in IR.
      
      All targets are expected to lower shuffles with identity masks
      efficiently.
      
      llvm-svn: 371340
      aff5bee3
    • Roman Lebedev's avatar
      [NFC][InstSimplify] Some tests for dropping null check after... · 64965430
      Roman Lebedev authored
      [NFC][InstSimplify] Some tests for dropping null check after uadd.with.overflow of non-null (PR43246)
      
      https://rise4fun.com/Alive/WRzq
      
      Name: C <= Y && Y != 0  -->  C <= Y  iff C != 0
      Pre: C != 0
        %y_is_nonnull = icmp ne i64 %y, 0
        %no_overflow = icmp ule i64 C, %y
        %r = and i1 %y_is_nonnull, %no_overflow
      =>
        %r = %no_overflow
      
      Name: C <= Y || Y != 0  -->  Y != 0  iff C != 0
      Pre: C != 0
        %y_is_nonnull = icmp ne i64 %y, 0
        %no_overflow = icmp ule i64 C, %y
        %r = or i1 %y_is_nonnull, %no_overflow
      =>
        %r = %y_is_nonnull
      
      Name: C > Y || Y == 0  -->  C > Y  iff C != 0
      Pre: C != 0
        %y_is_null = icmp eq i64 %y, 0
        %overflow = icmp ugt i64 C, %y
        %r = or i1 %y_is_null, %overflow
      =>
        %r = %overflow
      
      Name: C > Y && Y == 0  -->  Y == 0  iff C != 0
      Pre: C != 0
        %y_is_null = icmp eq i64 %y, 0
        %overflow = icmp ugt i64 C, %y
        %r = and i1 %y_is_null, %overflow
      =>
        %r = %y_is_null
      
      https://bugs.llvm.org/show_bug.cgi?id=43246
      
      llvm-svn: 371339
      64965430
    • Kamil Rytarowski's avatar
      Enable LSan tests for NetBSD/i386 · def6ca8b
      Kamil Rytarowski authored
      llvm-svn: 371338
      def6ca8b
    • Kamil Rytarowski's avatar
      Stop marking 5 ASan tests as failing on NetBSD/i386 · 90d2be01
      Kamil Rytarowski authored
      Unexpected Passing Tests (4):
          AddressSanitizer-i386-netbsd :: TestCases/Posix/coverage-reset.cpp
          AddressSanitizer-i386-netbsd :: TestCases/Posix/coverage.cpp
          AddressSanitizer-i386-netbsd :: TestCases/Posix/interception-in-shared-lib-test.cpp
          AddressSanitizer-i386-netbsd :: TestCases/suppressions-library.cpp
      
      llvm-svn: 371337
      90d2be01
    • Jonas Hahnfeld's avatar
      [ASan] Only run dlopen-mixed-c-cxx.c with static runtime · 307daa71
      Jonas Hahnfeld authored
      This is what the original bug (http://llvm.org/PR39641) and the fix
      in https://reviews.llvm.org/D63877 have been about.
      With the dynamic runtime the test only passes when the asan library
      is linked against libstdc++: In contrast to libc++abi, it does not
      implement __cxa_rethrow_primary_exception so the regex matches the
      line saying that asan cannot intercept this function. Indeed, there
      is no message that the runtime failed to intercept  __cxa_throw.
      
      Differential Revision: https://reviews.llvm.org/D67298
      
      llvm-svn: 371336
      307daa71
  2. Sep 08, 2019
  3. Sep 07, 2019