Closed oroppas closed 3 years ago
The FIR generated here is wrong, I think a transformation/optimization pass moved the fir.extract_op positional argument as a block argument of ^bb3
that does not play well with the fact code generation is then trying to get a constant value from the argument.
^bb3(%19: index, %20: index): // 2 preds: ^bb2, ^bb4
%21 = fir.load %arg0 : !fir.ref<!fir.complex<8>>
%22 = fir.extract_value %21, %19 : (!fir.complex<8>, index) -> f64
@oroppas , do you have the original Fortran source to investigate which pass is doing this rewrite and why ?
@schweitzpgi, should ExtractValueOp/InsertValueOp take the positional arguments as attributes instead of values to ensure by construction they are constants and prevent this kind of obfuscation during transformation passes ?
@jeanPerier
This is the original code lapack-3.9.1/TESTING/EIG/zlctes.f
*> \brief \b ZLCTES
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* LOGICAL FUNCTION ZLCTES( Z, D )
*
* .. Scalar Arguments ..
* COMPLEX*16 D, Z
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> ZLCTES returns .TRUE. if the eigenvalue Z/D is to be selected
*> (specifically, in this subroutine, if the real part of the
*> eigenvalue is negative), and otherwise it returns .FALSE..
*>
*> It is used by the test routine ZDRGES to test whether the driver
*> routine ZGGES successfully sorts eigenvalues.
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] Z
*> \verbatim
*> Z is COMPLEX*16
*> The numerator part of a complex eigenvalue Z/D.
*> \endverbatim
*>
*> \param[in] D
*> \verbatim
*> D is COMPLEX*16
*> The denominator part of a complex eigenvalue Z/D.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \ingroup complex16_eig
*
* =====================================================================
LOGICAL FUNCTION ZLCTES( Z, D )
*
* -- LAPACK test routine --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
*
* .. Scalar Arguments ..
COMPLEX*16 D, Z
* ..
*
* =====================================================================
*
* .. Parameters ..
*
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
COMPLEX*16 CZERO
PARAMETER ( CZERO = ( 0.0D+0, 0.0D+0 ) )
* ..
* .. Local Scalars ..
DOUBLE PRECISION ZMAX
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, DBLE, DIMAG, MAX, SIGN
* ..
* .. Executable Statements ..
*
IF( D.EQ.CZERO ) THEN
ZLCTES = ( DBLE( Z ).LT.ZERO )
ELSE
IF( DBLE( Z ).EQ.ZERO .OR. DBLE( D ).EQ.ZERO ) THEN
ZLCTES = ( SIGN( ONE, DIMAG( Z ) ).NE.
$ SIGN( ONE, DIMAG( D ) ) )
ELSE IF( DIMAG( Z ).EQ.ZERO .OR. DIMAG( D ).EQ.ZERO ) THEN
ZLCTES = ( SIGN( ONE, DBLE( Z ) ).NE.
$ SIGN( ONE, DBLE( D ) ) )
ELSE
ZMAX = MAX( ABS( DBLE( Z ) ), ABS( DIMAG( Z ) ) )
ZLCTES = ( ( DBLE( Z ) / ZMAX )*DBLE( D )+
$ ( DIMAG( Z ) / ZMAX )*DIMAG( D ).LT.ZERO )
END IF
END IF
*
RETURN
*
* End of ZLCTES
*
END
@schweitzpgi, should ExtractValueOp/InsertValueOp take the positional arguments as attributes instead of values to ensure by construction they are constants and prevent this kind of obfuscation during transformation passes ?
Yes, that sounds like the right approach here.
See #841
@oroppas Can you try this again and see if the issue is resolved? Thanks.
Yes, it's resolved. Thanks!
tco
crashes on the following mlirHere's stack dump