[llvm] 4813c36 - [InstCombine] Avoid UB in tests (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 22 06:43:06 PDT 2023


Author: Nikita Popov
Date: 2023-06-22T15:42:56+02:00
New Revision: 4813c36db2097876780425368ba3e852919899e7

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

LOG: [InstCombine] Avoid UB in tests (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/and-or-icmps.ll
    llvm/test/Transforms/InstCombine/maxnum.ll
    llvm/test/Transforms/InstCombine/minnum.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/and-or-icmps.ll b/llvm/test/Transforms/InstCombine/and-or-icmps.ll
index d7dedf8daa587..3a55982a6fa9e 100644
--- a/llvm/test/Transforms/InstCombine/and-or-icmps.ll
+++ b/llvm/test/Transforms/InstCombine/and-or-icmps.ll
@@ -362,7 +362,7 @@ define <2 x i1> @and_ne_with_
diff _one_splatvec(<2 x i32> %x) {
 ; on an 'and' that should have been killed. It's not obvious
 ; why, but removing anything hides the bug, hence the long test.
 
-define void @simplify_before_foldAndOfICmps() {
+define void @simplify_before_foldAndOfICmps(ptr %p) {
 ; CHECK-LABEL: @simplify_before_foldAndOfICmps(
 ; CHECK-NEXT:    [[A8:%.*]] = alloca i16, align 2
 ; CHECK-NEXT:    [[L7:%.*]] = load i16, ptr [[A8]], align 2
@@ -379,9 +379,9 @@ define void @simplify_before_foldAndOfICmps() {
 ; CHECK-NEXT:    [[C18:%.*]] = or i1 [[C7]], [[TMP3]]
 ; CHECK-NEXT:    [[TMP4:%.*]] = sext i1 [[C3]] to i64
 ; CHECK-NEXT:    [[G26:%.*]] = getelementptr i1, ptr null, i64 [[TMP4]]
-; CHECK-NEXT:    store i16 [[L7]], ptr undef, align 2
-; CHECK-NEXT:    store i1 [[C18]], ptr undef, align 1
-; CHECK-NEXT:    store ptr [[G26]], ptr undef, align 8
+; CHECK-NEXT:    store i16 [[L7]], ptr [[P:%.*]], align 2
+; CHECK-NEXT:    store i1 [[C18]], ptr [[P]], align 1
+; CHECK-NEXT:    store ptr [[G26]], ptr [[P]], align 8
 ; CHECK-NEXT:    ret void
 ;
   %A8 = alloca i16
@@ -412,9 +412,9 @@ define void @simplify_before_foldAndOfICmps() {
   store i16 undef, ptr %G21
   %C18 = icmp ule i1 %C10, %C7
   %G26 = getelementptr i1, ptr null, i1 %C3
-  store i16 %B33, ptr undef
-  store i1 %C18, ptr undef
-  store ptr %G26, ptr undef
+  store i16 %B33, ptr %p
+  store i1 %C18, ptr %p
+  store ptr %G26, ptr %p
   ret void
 }
 

diff  --git a/llvm/test/Transforms/InstCombine/maxnum.ll b/llvm/test/Transforms/InstCombine/maxnum.ll
index 27a2c70333b3b..87288b18cbcd9 100644
--- a/llvm/test/Transforms/InstCombine/maxnum.ll
+++ b/llvm/test/Transforms/InstCombine/maxnum.ll
@@ -400,35 +400,35 @@ define float @reduce_precision_fmf(float %x, float %y) {
   ret float %trunc
 }
 
-define float @reduce_precision_multi_use_0(float %x, float %y) {
+define float @reduce_precision_multi_use_0(float %x, float %y, ptr %p) {
 ; CHECK-LABEL: @reduce_precision_multi_use_0(
 ; CHECK-NEXT:    [[X_EXT:%.*]] = fpext float [[X:%.*]] to double
 ; CHECK-NEXT:    [[Y_EXT:%.*]] = fpext float [[Y:%.*]] to double
-; CHECK-NEXT:    store double [[X_EXT]], ptr undef, align 8
+; CHECK-NEXT:    store double [[X_EXT]], ptr [[P:%.*]], align 8
 ; CHECK-NEXT:    [[MAXNUM:%.*]] = call double @llvm.maxnum.f64(double [[X_EXT]], double [[Y_EXT]])
 ; CHECK-NEXT:    [[TRUNC:%.*]] = fptrunc double [[MAXNUM]] to float
 ; CHECK-NEXT:    ret float [[TRUNC]]
 ;
   %x.ext = fpext float %x to double
   %y.ext = fpext float %y to double
-  store double %x.ext, ptr undef
+  store double %x.ext, ptr %p
   %maxnum = call double @llvm.maxnum.f64(double %x.ext, double %y.ext)
   %trunc = fptrunc double %maxnum to float
   ret float %trunc
 }
 
-define float @reduce_precision_multi_use_1(float %x, float %y) {
+define float @reduce_precision_multi_use_1(float %x, float %y, ptr %p) {
 ; CHECK-LABEL: @reduce_precision_multi_use_1(
 ; CHECK-NEXT:    [[X_EXT:%.*]] = fpext float [[X:%.*]] to double
 ; CHECK-NEXT:    [[Y_EXT:%.*]] = fpext float [[Y:%.*]] to double
-; CHECK-NEXT:    store double [[Y_EXT]], ptr undef, align 8
+; CHECK-NEXT:    store double [[Y_EXT]], ptr [[P:%.*]], align 8
 ; CHECK-NEXT:    [[MAXNUM:%.*]] = call double @llvm.maxnum.f64(double [[X_EXT]], double [[Y_EXT]])
 ; CHECK-NEXT:    [[TRUNC:%.*]] = fptrunc double [[MAXNUM]] to float
 ; CHECK-NEXT:    ret float [[TRUNC]]
 ;
   %x.ext = fpext float %x to double
   %y.ext = fpext float %y to double
-  store double %y.ext, ptr undef
+  store double %y.ext, ptr %p
   %maxnum = call double @llvm.maxnum.f64(double %x.ext, double %y.ext)
   %trunc = fptrunc double %maxnum to float
   ret float %trunc

diff  --git a/llvm/test/Transforms/InstCombine/minnum.ll b/llvm/test/Transforms/InstCombine/minnum.ll
index 3fb267d6b9961..8050f07559527 100644
--- a/llvm/test/Transforms/InstCombine/minnum.ll
+++ b/llvm/test/Transforms/InstCombine/minnum.ll
@@ -437,35 +437,35 @@ define float @reduce_precision_fmf(float %x, float %y) {
   ret float %trunc
 }
 
-define float @reduce_precision_multi_use_0(float %x, float %y) {
+define float @reduce_precision_multi_use_0(float %x, float %y, ptr %p) {
 ; CHECK-LABEL: @reduce_precision_multi_use_0(
 ; CHECK-NEXT:    [[X_EXT:%.*]] = fpext float [[X:%.*]] to double
 ; CHECK-NEXT:    [[Y_EXT:%.*]] = fpext float [[Y:%.*]] to double
-; CHECK-NEXT:    store double [[X_EXT]], ptr undef, align 8
+; CHECK-NEXT:    store double [[X_EXT]], ptr [[P:%.*]], align 8
 ; CHECK-NEXT:    [[MINNUM:%.*]] = call double @llvm.minnum.f64(double [[X_EXT]], double [[Y_EXT]])
 ; CHECK-NEXT:    [[TRUNC:%.*]] = fptrunc double [[MINNUM]] to float
 ; CHECK-NEXT:    ret float [[TRUNC]]
 ;
   %x.ext = fpext float %x to double
   %y.ext = fpext float %y to double
-  store double %x.ext, ptr undef
+  store double %x.ext, ptr %p
   %minnum = call double @llvm.minnum.f64(double %x.ext, double %y.ext)
   %trunc = fptrunc double %minnum to float
   ret float %trunc
 }
 
-define float @reduce_precision_multi_use_1(float %x, float %y) {
+define float @reduce_precision_multi_use_1(float %x, float %y, ptr %p) {
 ; CHECK-LABEL: @reduce_precision_multi_use_1(
 ; CHECK-NEXT:    [[X_EXT:%.*]] = fpext float [[X:%.*]] to double
 ; CHECK-NEXT:    [[Y_EXT:%.*]] = fpext float [[Y:%.*]] to double
-; CHECK-NEXT:    store double [[Y_EXT]], ptr undef, align 8
+; CHECK-NEXT:    store double [[Y_EXT]], ptr [[P:%.*]], align 8
 ; CHECK-NEXT:    [[MINNUM:%.*]] = call double @llvm.minnum.f64(double [[X_EXT]], double [[Y_EXT]])
 ; CHECK-NEXT:    [[TRUNC:%.*]] = fptrunc double [[MINNUM]] to float
 ; CHECK-NEXT:    ret float [[TRUNC]]
 ;
   %x.ext = fpext float %x to double
   %y.ext = fpext float %y to double
-  store double %y.ext, ptr undef
+  store double %y.ext, ptr %p
   %minnum = call double @llvm.minnum.f64(double %x.ext, double %y.ext)
   %trunc = fptrunc double %minnum to float
   ret float %trunc


        


More information about the llvm-commits mailing list