Skip to content

JIT: Incorrect optimization of x & -x on x86 #66709

@jakobbotsch

Description

@jakobbotsch

Description

The following program gives an invalid result when optimizing on x86.

Reproduction Steps

// Generated by Fuzzlyn v1.5 on 2022-03-16 11:07:55
// Run on X86 Windows
// Seed: 13083630089409025722
// Reduced from 309.3 KiB to 0.2 KiB in 00:06:28
// Debug: Outputs 1
// Release: Outputs 4294967297
public class Program
{
    public static long s_61 = -1;
    public static void Main()
    {
        s_61 &= -s_61;
        System.Console.WriteLine(s_61);
    }
}

Expected behavior

Same result with and without optimizations.

Actual behavior

Different result.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

Probably some interaction between long decomposition and the new optimization added in #66193? cc @Wraith2 @dotnet/jit-contrib

Metadata

Metadata

Assignees

Labels

arch-x86area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIbug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions