Skip to content

Wrong xor --> or disjoint due to undef inputs #96857

Closed
@bongjunj

Description

@bongjunj

https://alive2.llvm.org/ce/z/XMy5BD

define i32 @fun0(i32 %val0, i32 %val1, i32 %val2) {
  %val4 = and i32 %val2, %val0
  %val5 = xor i32 %val2, -1
  %val6 = and i32 %val5, %val1
  %val7 = xor i32 %val4, %val6
  ret i32 %val7
}
----------------------------------------
define i32 @fun0(i32 %val0, i32 %val1, i32 %val2) {
#0:
  %val4 = and i32 %val2, %val0
  %val5 = xor i32 %val2, 4294967295
  %val6 = and i32 %val5, %val1
  %val7 = xor i32 %val4, %val6
  ret i32 %val7
}
=>
define i32 @fun0(i32 %val0, i32 %val1, i32 %val2) {
#0:
  %val4 = and i32 %val2, %val0
  %val5 = xor i32 %val2, 4294967295
  %val6 = and i32 %val5, %val1
  %val7 = or disjoint i32 %val4, %val6
  ret i32 %val7
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
i32 %val0 = undef
i32 %val1 = undef
i32 %val2 = undef

Source:
i32 %val4 = #x00000000 (0)	[based on undef value]
i32 %val5 = #xffffffff (4294967295, -1)	[based on undef value]
i32 %val6 = #x00000000 (0)	[based on undef value]
i32 %val7 = #x00000000 (0)

Target:
i32 %val4 = #x0000000f (15)
i32 %val5 = #xffffffff (4294967295, -1)
i32 %val6 = #x0000000f (15)
i32 %val7 = poison
Source value: #x00000000 (0)
Target value: poison

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions