[llvm] b7af286 - [InstCombine] Add test for "or disjoint" miscompile (NFC)

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


Author: Nikita Popov
Date: 2023-11-30T16:23:00+01:00
New Revision: b7af286a4e3e2e5464b95ddfca0ed793bb4aa8b9

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

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

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/phi.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/phi.ll b/llvm/test/Transforms/InstCombine/phi.ll
index bdd5da5bdba3636..787cad287406c6b 100644
--- a/llvm/test/Transforms/InstCombine/phi.ll
+++ b/llvm/test/Transforms/InstCombine/phi.ll
@@ -1421,6 +1421,37 @@ if.end:
   ret i1  %cmp1
 }
 
+; FIXME: This is a miscompile.
+define i1 @phi_knownnonzero_eq_or_disjoint_icmp(i32 %n, i32 %s, ptr %P, i32 %val) {
+; CHECK-LABEL: @phi_knownnonzero_eq_or_disjoint_icmp(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp slt i32 [[N:%.*]], [[S:%.*]]
+; CHECK-NEXT:    br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+; CHECK:       if.then:
+; CHECK-NEXT:    br label [[IF_END]]
+; CHECK:       if.end:
+; CHECK-NEXT:    [[PHI:%.*]] = phi i32 [ 1, [[IF_THEN]] ], [ [[N]], [[ENTRY:%.*]] ]
+; CHECK-NEXT:    [[ORPHI:%.*]] = or disjoint i32 [[PHI]], [[VAL:%.*]]
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i32 [[ORPHI]], 0
+; CHECK-NEXT:    ret i1 [[CMP1]]
+;
+entry:
+  %tobool = icmp slt  i32 %n, %s
+  br i1 %tobool, label %if.end, label %if.then
+
+if.then:
+  %load = load i32, ptr %P
+  %cmp = icmp eq i32 %n, %load
+  %sel = select i1 %cmp, i32 1, i32 2
+  br label %if.end
+
+if.end:
+  %phi = phi i32 [ %sel,  %if.then ], [ %n, %entry ]
+  %orphi = or disjoint i32 %phi, %val
+  %cmp1 = icmp eq i32 %orphi, 0
+  ret i1  %cmp1
+}
+
 define i1 @phi_knownnonzero_ne_oricmp(i32 %n, i32 %s, ptr %P, i32 %val) {
 ; CHECK-LABEL: @phi_knownnonzero_ne_oricmp(
 ; CHECK-NEXT:  entry:


        


More information about the llvm-commits mailing list