[llvm] 2544882 - [InstSimplify] Update test to make miscompile more obvious (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 4 07:08:17 PST 2022


Author: Nikita Popov
Date: 2022-01-04T16:08:09+01:00
New Revision: 25448826dd4c1965be08fa38cc02de9551084262

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

LOG: [InstSimplify] Update test to make miscompile more obvious (NFC)

This is now testing (null + g3) != g3 and still coming up with
"true" as the answer. The original case was a less obvious
miscompile with index overflow involved.

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll b/llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll
index 99f1a16c5427d..cdf6be0e52435 100644
--- a/llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll
+++ b/llvm/test/Transforms/InstSimplify/ConstProp/icmp-global.ll
@@ -66,6 +66,7 @@ define i1 @ult_constexpr_constexpr_one(i8* %x) {
 @g = global [2 x i32] [i32 1, i32 2]
 @g2 = global i32 0
 @g2_weak = extern_weak global i32
+ at g3 = global i8 0
 
 define i1 @global_ne_null() {
 ; CHECK-LABEL: @global_ne_null(
@@ -169,8 +170,8 @@ define i1 @null_gep_ne_global() {
 ; CHECK-LABEL: @null_gep_ne_global(
 ; CHECK-NEXT:    ret i1 true
 ;
-  %gep = getelementptr [2 x i32], [2 x i32]* null, i64 ptrtoint (i32* @g2 to i64)
-  %cmp = icmp ne [2 x i32]* %gep, @g
+  %gep = getelementptr i8, i8* null, i64 ptrtoint (i8* @g3 to i64)
+  %cmp = icmp ne i8* %gep, @g3
   ret i1 %cmp
 }
 
@@ -178,8 +179,8 @@ define i1 @null_gep_ult_global() {
 ; CHECK-LABEL: @null_gep_ult_global(
 ; CHECK-NEXT:    ret i1 true
 ;
-  %gep = getelementptr [2 x i32], [2 x i32]* null, i64 ptrtoint (i32* @g2 to i64)
-  %cmp = icmp ult [2 x i32]* %gep, @g
+  %gep = getelementptr i8, i8* null, i64 ptrtoint (i8* @g3 to i64)
+  %cmp = icmp ult i8* %gep, @g3
   ret i1 %cmp
 }
 


        


More information about the llvm-commits mailing list