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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 08:05:08 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
+  %idxprom3 = sext i32 %add to i64
+  %arrayidx4 = getelementptr [2 x [1 x [2 x i8]]], ptr %f, i64 0, i64 %idxprom3
+  %arrayidx8 = getelementptr [2 x i8], ptr %arrayidx4, i64 0, i64 %idxprom3
+  br label %if.end
----------------
fhahn wrote:

Does this need the unconditional branch to reproduce?

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


More information about the llvm-commits mailing list