Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

1 XOR 1 computes to 1 in release mode #80711

Closed
bradmarder opened this issue Jan 16, 2023 · 4 comments
Closed

1 XOR 1 computes to 1 in release mode #80711

bradmarder opened this issue Jan 16, 2023 · 4 comments
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug
Milestone

Comments

@bradmarder
Copy link

Description

@jakobbotsch

1 ^ 1 should compute to 0 in release mode.

Reproduction Steps

// Generated by Fuzzlyn v1.5 on 2023-01-16 17:01:38
// Run on X64 Windows
// Seed: 10178493004625664135
// Reduced from 625.1 KiB to 1.5 KiB in 00:03:14
// Debug: Outputs 0
// Release: Outputs 1
public struct S0
{
	public bool F1;
}

public struct S1
{
	public S0 F2;
}

public class Program
{
	public static ushort s_19;
	public static S1 s_21;
	public static ushort[] s_32;

	public static void Main()
	{
		ulong[] vr0 = new ulong[] { 0 };
		for (int vr1 = 0; vr1 < 2; vr1++)
		{
			vr0[0] = 1;
			if (s_21.F2.F1)
			{
				s_32[0] = s_19;
			}

			vr0[0] ^= vr0[0];
			Console.WriteLine(vr1);
		}
		Console.WriteLine(vr0[0]);
	}
}

Expected behavior

1 ^ 1 should compute to 0.

Actual behavior

1 ^ 1 computes to 1.

Regression?

No, reproduces in net6.

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jan 16, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jan 16, 2023
@ghost
Copy link

ghost commented Jan 16, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

@jakobbotsch

1 ^ 1 should compute to 0 in release mode.

Reproduction Steps

// Generated by Fuzzlyn v1.5 on 2023-01-16 17:01:38
// Run on X64 Windows
// Seed: 10178493004625664135
// Reduced from 625.1 KiB to 1.5 KiB in 00:03:14
// Debug: Outputs 0
// Release: Outputs 1
public struct S0
{
	public bool F1;
}

public struct S1
{
	public S0 F2;
}

public class Program
{
	public static ushort s_19;
	public static S1 s_21;
	public static ushort[] s_32;

	public static void Main()
	{
		ulong[] vr0 = new ulong[] { 0 };
		for (int vr1 = 0; vr1 < 2; vr1++)
		{
			vr0[0] = 1;
			if (s_21.F2.F1)
			{
				s_32[0] = s_19;
			}

			vr0[0] ^= vr0[0];
			Console.WriteLine(vr1);
		}
		Console.WriteLine(vr0[0]);
	}
}

Expected behavior

1 ^ 1 should compute to 0.

Actual behavior

1 ^ 1 computes to 1.

Regression?

No, reproduces in net6.

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: bradmarder
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@EgorBo
Copy link
Member

EgorBo commented Jan 16, 2023

From a quick glance it's Loop Hoisting hoisted vr0[0]

@EgorBo EgorBo added bug and removed untriaged New issue has not been triaged by the area owner labels Jan 16, 2023
@EgorBo EgorBo added this to the 8.0.0 milestone Jan 16, 2023
@jakobbotsch
Copy link
Member

This is probably a duplicate of #75442.

@jakobbotsch
Copy link
Member

Closing as a dup of #75442

@jakobbotsch jakobbotsch closed this as not planned Won't fix, can't repro, duplicate, stale Jun 20, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Jul 20, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI bug
Projects
None yet
Development

No branches or pull requests

3 participants