[llvm] [CodeGenPrepare] Replace deleted sext instr with the promoted value. (PR #71058)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 10:56:02 PDT 2023


================
@@ -507,3 +507,26 @@ define i8 @oneArgPromotionBlockSExtZExt(i1 %arg1, ptr %base) {
   %res = load i8, ptr %arrayidx
   ret i8 %res
 }
+
+; Check that we replace the deleted sext with the promoted value.
+; CHECK-LABEL: define void @pr70938(
+; CHECK-SAME: ptr [[F:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[ADD:%.*]] = add nsw i64 0, 1
+; CHECK-NEXT:    [[SUNKADDR:%.*]] = mul i64 [[ADD]], 2
+; CHECK-NEXT:    [[SUNKADDR1:%.*]] = getelementptr i8, ptr [[F]], i64 [[SUNKADDR]]
+; CHECK-NEXT:    [[SUNKADDR2:%.*]] = getelementptr i8, ptr [[SUNKADDR1]], i64 1
+; CHECK-NEXT:    store i8 0, ptr [[SUNKADDR2]], align 1
+; CHECK-NEXT:    ret void
+define void @pr70938(ptr %f) {
+entry:
+  %add = add nsw i32 0, 1
----------------
dtcxzyw wrote:

Sorry, I cannot reproduce the error even with a slight modification in the test case. It is a fuzzer-generated case :(

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


More information about the llvm-commits mailing list