[all-commits] [llvm/llvm-project] 459134: [InstCombine] Pre-commit of test case showing misc...

Björn Pettersson via All-commits all-commits at lists.llvm.org
Fri Oct 18 00:40:54 PDT 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 459134064daeef03a762979ab162587f94361cdc
      https://github.com/llvm/llvm-project/commit/459134064daeef03a762979ab162587f94361cdc
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2019-10-18 (Fri, 18 Oct 2019)

  Changed paths:
    A llvm/test/Transforms/InstCombine/shufflevector-div-rem.ll

  Log Message:
  -----------
  [InstCombine] Pre-commit of test case showing miscompile bug in canEvaluateShuffled

Adding the reproducer from  https://bugs.llvm.org/show_bug.cgi?id=43689,
showing that instcombine is doing a bad transform. It transforms

  %0 = insertelement <2 x i16> undef, i16 %a, i32 0
  %1 = srem <2 x i16> %0, <i16 2, i16 1>
  %2 = shufflevector <2 x i16> %1, <2 x i16> undef, <2 x i32> <i32 undef, i32 0>

into

   %1 = insertelement <2 x i16> undef, i16 %a, i32 1
   %2 = srem <2 x i16> %1, <i16 undef, i16 2>

The undef denominator makes the whole srem undefined.

llvm-svn: 375207


  Commit: 6456252dbf67f26f88873e92c0813ebf8a1f96a3
      https://github.com/llvm/llvm-project/commit/6456252dbf67f26f88873e92c0813ebf8a1f96a3
  Author: Bjorn Pettersson <bjorn.a.pettersson at ericsson.com>
  Date:   2019-10-18 (Fri, 18 Oct 2019)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
    M llvm/test/Transforms/InstCombine/shufflevector-div-rem.ll

  Log Message:
  -----------
  [InstCombine] Fix miscompile bug in canEvaluateShuffled

Summary:
Add restrictions in canEvaluateShuffled to prevent that we for example
transform

  %0 = insertelement <2 x i16> undef, i16 %a, i32 0
  %1 = srem <2 x i16> %0, <i16 2, i16 1>
  %2 = shufflevector <2 x i16> %1, <2 x i16> undef, <2 x i32> <i32 undef, i32 0>

into

   %1 = insertelement <2 x i16> undef, i16 %a, i32 1
   %2 = srem <2 x i16> %1, <i16 undef, i16 2>

as having an undef denominator makes the srem undefined (for all
vector elements).

Fixes: https://bugs.llvm.org/show_bug.cgi?id=43689

Reviewers: spatel, lebedev.ri

Reviewed By: spatel, lebedev.ri

Subscribers: lebedev.ri, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 375208


Compare: https://github.com/llvm/llvm-project/compare/9a5ad9bd5ad1...6456252dbf67


More information about the All-commits mailing list