Skip to content

Commit a9ea02d

Browse files
committed
Recommit "[ConstraintElim] Treat ConstantPointerNull as constant offset 0."
This reverts commit 58286f9. Now with the test correctly updated. Original message: Treat ConstantPointerNull (null) as constant offset 0 in the constraint instead of a variable. This slightly reduces the number of variables. I was not able to find a test case where this actually caused any changes.
1 parent e1afd06 commit a9ea02d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ static Decomposition decompose(Value *V,
455455
if (Ty->isPointerTy() && !IsSigned) {
456456
if (auto *GEP = dyn_cast<GEPOperator>(V))
457457
return decomposeGEP(*GEP, Preconditions, IsSigned, DL);
458+
if (isa<ConstantPointerNull>(V))
459+
return int64_t(0);
460+
458461
return V;
459462
}
460463

llvm/test/Transforms/ConstraintElimination/reproducer-remarks-debug.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
66

77
; CHECK: Condition %c.2 = icmp eq ptr %a, null implied by dominating constraints
8-
; CHECK-NEXT: %a + -1 * null <= 0
8+
; CHECK-NEXT: %a <= 0
99
; CHECK-NEXT: Creating reproducer for %c.2 = icmp eq ptr %a, null
1010
; CHECK-NEXT: found external input ptr %a
1111
; CHECK-NEXT: Materializing assumption icmp eq ptr %a, null

0 commit comments

Comments
 (0)