[llvm] [LV] Add extra check for signed oveflow for SDiv/SRem (PR #170818)

Shih-Po Hung via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 5 10:05:22 PST 2025


================
@@ -115,7 +115,8 @@ define void @loop_invariant_srem(ptr %p, i64 %a, i8 %b) {
 ; CHECK-NEXT:    [[PREDPHI:%.*]] = select <4 x i1> [[TMP5]], <4 x i32> [[TMP3]], <4 x i32> [[TMP2]]
 ; CHECK-NEXT:    [[TMP7:%.*]] = shl <4 x i32> [[PREDPHI]], splat (i32 8)
 ; CHECK-NEXT:    [[TMP8:%.*]] = trunc <4 x i32> [[TMP7]] to <4 x i8>
-; CHECK-NEXT:    [[TMP11:%.*]] = srem <4 x i8> [[VEC_IND1]], [[TMP8]]
+; CHECK-NEXT:    [[TMP9:%.*]] = select <4 x i1> [[TMP4]], <4 x i8> [[TMP8]], <4 x i8> splat (i8 1)
+; CHECK-NEXT:    [[TMP11:%.*]] = srem <4 x i8> [[VEC_IND1]], [[TMP9]]
----------------
arcbbb wrote:

%trunc could be -1, but %iv won't reach INT_MIN.  this still needs fine-tuning.

https://github.com/llvm/llvm-project/pull/170818


More information about the llvm-commits mailing list