Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
It would be good to add tests for the sitofp case as well.
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | ||
---|---|---|
1760 | Can use IC.computeKnownBits(Src, 0, &I) to also make use of AC/DT, I believe. | |
llvm/test/Transforms/InstCombine/sitofp.ll | ||
245 | According to alive, this mask would be fine: https://alive2.llvm.org/ce/z/PdpF6F This is because this is a mask of the form 0b1000... rather than 0b1111.... The right mask to test would be: https://alive2.llvm.org/ce/z/GYxTRu (We could also make use of these low zero bits, but I think that would be better as a separate change.) |
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | ||
---|---|---|
1946 | We should have at least one test providing coverage for this path (and fpext too?). IIUC, this patch will improve a case like this: define half @masked_int_to_fp_trunc(i32 %A) { %m = and i32 %A, 16777215 %B = sitofp i32 %m to float %C = fptrunc float %B to half ret half %C } But we don't actually need a mask: |
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | ||
---|---|---|
1946 | hi @spatel, I think the case in your link https://alive2.llvm.org/ce/z/iaEX2i is related to another top, maybe make use of the fptrunc?
%m = and i25 %A, smallMaskValue %B = uitofp i25 %m to float %C = fptoui float %B to i25
#0 isKnownExactCastIntToFP (I=..., IC=...) at /home/zhongyunde/llvm-project-init-dev_12x/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:1762 #1 0x0000aaaaae7ee18c in llvm::InstCombinerImpl::foldItoFPtoI (this=0xffffffffbce0, FI=...) at /home/zhongyunde/llvm-project-init-dev_12x/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:1986 #2 0x0000aaaaae7ee398 in llvm::InstCombinerImpl::visitFPToUI (this=0xffffffffbce0, FI=...) at /home/zhongyunde/llvm-project-init-dev_12x/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:2011 |
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | ||
---|---|---|
1946 | I understand that we are not optimizing ideally for this pattern, but that's not my point. |
I don't think this was updated correctly. There should be test diffs from the file fpcast.ll?
LGTM - clearly, we can still do better, but this seems like a safe improvement.
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | ||
---|---|---|
1758 | Please leave the TODO note. We could still check sign bits rather than zeros or do some other kind of refinement. |
Please leave the TODO note. We could still check sign bits rather than zeros or do some other kind of refinement.