[llvm] c89553a - [InstSimplify] Add test for or disjoint miscompile (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 07:55:46 PST 2023


Author: Nikita Popov
Date: 2023-11-30T16:55:32+01:00
New Revision: c89553ae829e05ac830eff80e69775704a8ba040

URL: https://github.com/llvm/llvm-project/commit/c89553ae829e05ac830eff80e69775704a8ba040
DIFF: https://github.com/llvm/llvm-project/commit/c89553ae829e05ac830eff80e69775704a8ba040.diff

LOG: [InstSimplify] Add test for or disjoint miscompile (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/select.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/select.ll b/llvm/test/Transforms/InstSimplify/select.ll
index c85c4d03000feaf..d0bb6c2613ef1b0 100644
--- a/llvm/test/Transforms/InstSimplify/select.ll
+++ b/llvm/test/Transforms/InstSimplify/select.ll
@@ -174,6 +174,18 @@ define i32 @test4(i32 %X) {
   ret i32 %cond
 }
 
+; FIXME: This is a miscompile.
+define i32 @test4_disjoint(i32 %X) {
+; CHECK-LABEL: @test4_disjoint(
+; CHECK-NEXT:    [[OR:%.*]] = or disjoint i32 [[X:%.*]], -2147483648
+; CHECK-NEXT:    ret i32 [[OR]]
+;
+  %cmp = icmp slt i32 %X, 0
+  %or = or disjoint i32 %X, -2147483648
+  %cond = select i1 %cmp, i32 %X, i32 %or
+  ret i32 %cond
+}
+
 ; Same as above, but the compare isn't canonical
 define i32 @test4noncanon(i32 %X) {
 ; CHECK-LABEL: @test4noncanon(
@@ -196,6 +208,16 @@ define i32 @test5(i32 %X) {
   ret i32 %cond
 }
 
+define i32 @test5_disjoint(i32 %X) {
+; CHECK-LABEL: @test5_disjoint(
+; CHECK-NEXT:    ret i32 [[X:%.*]]
+;
+  %cmp = icmp slt i32 %X, 0
+  %or = or disjoint i32 %X, -2147483648
+  %cond = select i1 %cmp, i32 %or, i32 %X
+  ret i32 %cond
+}
+
 define i32 @test6(i32 %X) {
 ; CHECK-LABEL: @test6(
 ; CHECK-NEXT:    [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
@@ -227,6 +249,16 @@ define i32 @test8(i32 %X) {
   ret i32 %cond
 }
 
+define i32 @test8_disjoint(i32 %X) {
+; CHECK-LABEL: @test8_disjoint(
+; CHECK-NEXT:    ret i32 [[X:%.*]]
+;
+  %cmp = icmp sgt i32 %X, -1
+  %or = or disjoint i32 %X, -2147483648
+  %cond = select i1 %cmp, i32 %X, i32 %or
+  ret i32 %cond
+}
+
 define i32 @test9(i32 %X) {
 ; CHECK-LABEL: @test9(
 ; CHECK-NEXT:    [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
@@ -238,6 +270,18 @@ define i32 @test9(i32 %X) {
   ret i32 %cond
 }
 
+; FIXME: This is a miscompile.
+define i32 @test9_disjoint(i32 %X) {
+; CHECK-LABEL: @test9_disjoint(
+; CHECK-NEXT:    [[OR:%.*]] = or disjoint i32 [[X:%.*]], -2147483648
+; CHECK-NEXT:    ret i32 [[OR]]
+;
+  %cmp = icmp sgt i32 %X, -1
+  %or = or disjoint i32 %X, -2147483648
+  %cond = select i1 %cmp, i32 %or, i32 %X
+  ret i32 %cond
+}
+
 ; Same as above, but the compare isn't canonical
 define i32 @test9noncanon(i32 %X) {
 ; CHECK-LABEL: @test9noncanon(


        


More information about the llvm-commits mailing list