[PATCH] D145278: Attributor: Start looking at uses when inferring nofpclass

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 17 03:54:30 PDT 2023


arsenm added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/AttributorAttributes.cpp:10307
+        followUsesInMBEC(*this, A, getState(), *CtxI);
+  }
+
----------------
jdoerfert wrote:
> This code doesn't seem to affect a test.
> I think something like this should work now:
> 
> ```
> call void @extern(%fp) willreturn nounwind ; < annotate this use
> call void @extern(nofpclass(nan inf) %fp)
> ```
It also doesn't change this test


================
Comment at: llvm/lib/Transforms/IPO/AttributorAttributes.cpp:10336
+
+    return clampStateAndIndicateChange(getState(), T);
   }
----------------
jdoerfert wrote:
> You can add a test with an alloca if you want to verify it works not only through PHIs but also memory.
Like this? Doesn't work


```
define float @returned_load(ptr %ptr) {
; CHECK: Function Attrs: nofree norecurse nosync nounwind willreturn memory(argmem: read)
; CHECK-LABEL: define float @returned_load
; CHECK-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[PTR:%.*]]) #[[ATTR4:[0-9]+]] {
; CHECK-NEXT:    [[LOAD:%.*]] = load float, ptr [[PTR]], align 4
; CHECK-NEXT:    ret float [[LOAD]]
;
  %load = load float, ptr %ptr
  ret float %load
}

define float @pass_nofpclass_inf_through_memory(float nofpclass(inf) %arg) {
; TUNIT: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
; TUNIT-LABEL: define float @pass_nofpclass_inf_through_memory
; TUNIT-SAME: (float nofpclass(inf) [[ARG:%.*]]) #[[ATTR2]] {
; TUNIT-NEXT:    [[ALLOCA:%.*]] = alloca float, align 4
; TUNIT-NEXT:    store float [[ARG]], ptr [[ALLOCA]], align 4
; TUNIT-NEXT:    [[RET:%.*]] = call float @returned_load(ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[ALLOCA]]) #[[ATTR7]]
; TUNIT-NEXT:    ret float [[RET]]
;
; CGSCC: Function Attrs: nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define float @pass_nofpclass_inf_through_memory
; CGSCC-SAME: (float nofpclass(inf) [[ARG:%.*]]) #[[ATTR3]] {
; CGSCC-NEXT:    [[ALLOCA:%.*]] = alloca float, align 4
; CGSCC-NEXT:    store float [[ARG]], ptr [[ALLOCA]], align 4
; CGSCC-NEXT:    [[RET:%.*]] = call float @returned_load(ptr noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[ALLOCA]]) #[[ATTR6]]
; CGSCC-NEXT:    ret float [[RET]]
;
  %alloca = alloca float
  store float %arg, ptr %alloca
  %ret = call float @returned_load(ptr %alloca)
  ret float %ret
}

```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145278/new/

https://reviews.llvm.org/D145278



More information about the llvm-commits mailing list