[llvm] [CodeGenPrepare] Replace deleted sext instr with the promoted value. (PR #71058)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 3 02:31:16 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
----------------
arsenm wrote:
Can you reproduce with a less contrived add that can't fold away?
https://github.com/llvm/llvm-project/pull/71058
More information about the llvm-commits
mailing list