[all-commits] [llvm/llvm-project] 3b7ec8: [flang] Use unix logical representation for fir.lo...

jeanPerier via All-commits all-commits at lists.llvm.org
Wed Mar 9 00:43:09 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3b7ec85a1e2cd3ba581e88543986fa5031f270b7
      https://github.com/llvm/llvm-project/commit/3b7ec85a1e2cd3ba581e88543986fa5031f270b7
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2022-03-09 (Wed, 09 Mar 2022)

  Changed paths:
    M flang/lib/Optimizer/CodeGen/CodeGen.cpp
    M flang/test/Fir/convert-to-llvm.fir

  Log Message:
  -----------
  [flang] Use unix logical representation for fir.logical

The front-end and the runtime are currently using the unix logical
representation, but lowering was not. These inconsistencies could
caused issues.

The only place that defines what the logical representation is in
lowering is the translation from FIR to LLVM (FIR is agnostic to the
actual representation). More precisely, the LLVM implementation of
`fir.convert` between `i1` and `fir.logcial` is what defines the
representation:
- `fir.convert` from `i1` to `fir.logical` defines the `.true.` and `.false.`
canonical representations
- `fir.convert` from `fir.logical` to `i1` decides what the test for
truth is.

Unix representation is:
- .true. canonical integer representation is 1
- .false. canonical integer representation is 0
- the test for truth is "integer representation != 0"

For the record, the previous representation that was used was in
codegen was:
- .true. canonical integer representation is -1 (all bits 1)
- .false. canonical integer representation is 0
- the test for truth is "integer representation lowest bit == 1"

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




More information about the All-commits mailing list