[all-commits] [llvm/llvm-project] e01a3d: [PatternMatch] Match XOR variant of unsigned-add o...

Florian Hahn via All-commits all-commits at lists.llvm.org
Wed Feb 19 06:26:55 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: e01a3d49c224d6f8a7afc01205b05b9deaa07afa
      https://github.com/llvm/llvm-project/commit/e01a3d49c224d6f8a7afc01205b05b9deaa07afa
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2020-02-19 (Wed, 19 Feb 2020)

  Changed paths:
    M llvm/include/llvm/IR/PatternMatch.h
    M llvm/lib/CodeGen/CodeGenPrepare.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/CodeGenPrepare/AArch64/overflow-intrinsics.ll
    M llvm/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll

  Log Message:
  -----------
  [PatternMatch] Match XOR variant of unsigned-add overflow check.

Instcombine folds (a + b <u a) to (a ^ -1 <u b) and that does not match
the expected pattern in CodeGenPerpare via UAddWithOverflow.

This causes a regression over Clang 7 on both X86 and AArch64:
https://gcc.godbolt.org/z/juhXYV

This patch extends UAddWithOverflow to also catch the XOR case, if the
XOR is only used in the ICMP. This covers just a single case, but I'd
like to make sure I am not missing anything before tackling the other
cases.

Reviewers: nikic, RKSimon, lebedev.ri, spatel

Reviewed By: nikic, lebedev.ri

Differential Revision: https://reviews.llvm.org/D74228




More information about the All-commits mailing list