[all-commits] [llvm/llvm-project] 83ba00: [flang] Handle special case for SHIFTA intrinsic

Valentin Clement (バレンタイン クレメン) via All-commits all-commits at lists.llvm.org
Thu Sep 1 07:28:27 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 83ba00bd2eb7ac13fe18edecb306c6c9e14d4d67
      https://github.com/llvm/llvm-project/commit/83ba00bd2eb7ac13fe18edecb306c6c9e14d4d67
  Author: Valentin Clement <clementval at gmail.com>
  Date:   2022-09-01 (Thu, 01 Sep 2022)

  Changed paths:
    M flang/lib/Lower/IntrinsicCall.cpp
    M flang/test/Lower/Intrinsics/shifta.f90

  Log Message:
  -----------
  [flang] Handle special case for SHIFTA intrinsic

This patch update the lowering of the shifta intrinsic to match
the behvior of gfortran. When the SHIFT value is equal to the
integer bitwidth then we handle it differently.
This is due to the operation used in lowering (`mlir::arith::ShRSIOp`)
that lowers to `ashr`.

Before this patch we have the following results:

```
SHIFTA(  -1, 8) =  0
SHIFTA(  -2, 8) =  0
SHIFTA( -30, 8) =  0
SHIFTA( -31, 8) =  0
SHIFTA( -32, 8) =  0
SHIFTA( -33, 8) =  0
SHIFTA(-126, 8) =  0
SHIFTA(-127, 8) =  0
SHIFTA(-128, 8) =  0
```

While gfortran is giving this:

```
SHIFTA(  -1, 8) = -1
SHIFTA(  -2, 8) = -1
SHIFTA( -30, 8) = -1
SHIFTA( -31, 8) = -1
SHIFTA( -32, 8) = -1
SHIFTA( -33, 8) = -1
SHIFTA(-126, 8) = -1
SHIFTA(-127, 8) = -1
SHIFTA(-128, 8) = -1
```

With this patch flang and gfortran have the same behavior.

Reviewed By: jeanPerier

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




More information about the All-commits mailing list