일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- TLS
- LLVM
- LLVM 난독화
- custom packer
- v8 tracing
- on-stack replacement
- pinpoint
- initial-exec
- Linux custom packer
- v8 optimizing
- on stack replacement
- 안티디버깅
- LLVM Obfuscator
- tracing
- linux thread
- linux debugging
- uftrace
- 난독화
- thread local storage
- Injection
- Linux packer
- anti debugging
- so inject
- Android
- OSR
- tracerpid
- apm
- Obfuscator
- android inject
- pthread
- Today
- Total
Why should I know this?
[InstCombine] Generalize folds for inversion of icmp operands 본문
[InstCombine] Generalize folds for inversion of icmp operands
die4taoam 2023. 12. 15. 03:37https://github.com/llvm/llvm-project/pull/74317
[InstCombine] Generalize folds for inversion of icmp operands by nikic · Pull Request #74317 · llvm/llvm-project
We have a bunch of folds that basically perform X pred Y to ~Y pred ~X for various special cases where this saves an instruction. Generalize these folds to use isFreeToInvert(). We have to make sur...
github.com
이 패치는 위와 같이 ICmp IR 에 특정한 패턴으로 NOT이 포함된 경우 NOT을 제거하는 것을 일반화 했다.
위 함수가 추가된 패치는 여기 있다.
https://github.com/ParkHanbum/llvm-project/commit/3039691f53487289bab40a4f889810ffd91980c2
내부 코드의 주석을 통해 Cmp문에서 좌우를 변경할 수 있는 경우를 정리할 수 있다.
다음 논리식을 참고하자.
https://die4taoam.tistory.com/152
LLVM 내부에서 활용되는 논리식 모음
~X NOT X A + B NOT -1 -B - A B - A NOT A + (-1 - B) A - B NOT B + (-1 - A) A ^ B NOT A ^ ~B A ^ ~B NOT A ^ B A s>> B NOT ~A s>>B 부연설명 A+B -> -1 -B -A (양->음전) 100+100 이라고 하면, 결과는 200, NOT은 -201이 나와야 함. -100 -100 -1
die4taoam.tistory.com
Icmp문에서는 삭제된 코드의 주석처럼 OP1 PRED OP2 에서 OP1과 OP2를 스왑할 때 NOT이 붙는다.
(~X ^ Y) == ~Z --> (X ^ Y) == Z
위 경우처럼. EQ은 NOT이 되도 EQ. 그러나 ~(~Z) -> Z, ~(~X ^ Y) -> (X^Y) 로 변경가능하다.
'LLVM-STUDY > PATCH' 카테고리의 다른 글
[LLVM] KnownBits를 활용한 최적화 패치 기록 남기기 (0) | 2024.05.14 |
---|---|
improve bitfield arithmetic #33784 (0) | 2023.12.20 |
Simplification Comparison for (a | b) ? (a ^ b) : (a & b) etc. (Clang13 vs Clang trunk (0) | 2023.11.12 |
[MemCpyOpt] The store instruction should not be removed by DSE. (0) | 2023.11.07 |
LLVM middle-end 최적화 관련 주의점(?) (0) | 2023.11.06 |