[PATCH] D71312: [InstCombine] Fold X / abs(X) to X < 0 ? -1 : 1
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 16:27:32 PST 2019
xbolva00 added a comment.
Isn't abs(INT_MIN) undefined?
expensive div is removed:
_Z4fooai: # @_Z4fooai
mov eax, edi
mov ecx, edi
neg ecx
cmovl ecx, edi
cdq
idiv ecx
ret
_Z5fooari: # @_Z5fooari
mov eax, edi
sar eax, 31
or eax, 1
ret
GCC knows this trick too.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71312/new/
https://reviews.llvm.org/D71312
More information about the llvm-commits
mailing list