[llvm] [LVI][SCCP][CVP] Add basic ConstantFPRange support (PR #111544)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 8 20:25:59 PST 2024
================
@@ -233,21 +233,22 @@ static Value *getValueOnEdge(LazyValueInfo *LVI, Value *Incoming,
// value can never be that constant. In that case replace the incoming
// value with the other value of the select. This often allows us to
// remove the select later.
+ if (!SI->getType()->isFPOrFPVectorTy()) {
----------------
dtcxzyw wrote:
It also handles the pointer case. See also Transforms/CorrelatedValuePropagation/basic.ll:
```
; "true" case for CorrelatedValuePropagation
define void @loop2(ptr %x, ptr %y) {
; CHECK-LABEL: define void @loop2
; CHECK-SAME: (ptr [[X:%.*]], ptr [[Y:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[PHI:%.*]] = phi ptr [ [[F:%.*]], [[LOOP]] ], [ [[X]], [[ENTRY:%.*]] ]
; CHECK-NEXT: [[F]] = tail call ptr @f(ptr [[PHI]])
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq ptr [[F]], [[Y]]
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP1]], ptr null, ptr [[F]]
; CHECK-NEXT: [[CMP2:%.*]] = icmp eq ptr [[SEL]], null
; CHECK-NEXT: br i1 [[CMP2]], label [[RETURN:%.*]], label [[LOOP]]
; CHECK: return:
; CHECK-NEXT: ret void
;
entry:
br label %loop
loop:
%phi = phi ptr [ %sel, %loop ], [ %x, %entry ]
%f = tail call ptr @f(ptr %phi)
%cmp1 = icmp eq ptr %f, %y
%sel = select i1 %cmp1, ptr null, ptr %f
%cmp2 = icmp eq ptr %sel, null
br i1 %cmp2, label %return, label %loop
return:
ret void
}
```
https://github.com/llvm/llvm-project/pull/111544
More information about the llvm-commits
mailing list