aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorNadav Rotem <nadav256@gmail.com>2022-01-20 09:25:45 -0800
committerNadav Rotem <nadav256@gmail.com>2022-01-20 09:31:46 -0800
commit191a6e9dfa1a54b616e12bde2efa849ad8e03f48 (patch)
treefd1a11d178240491ae5ae4884eef085eb7647bcd /clang/lib/CodeGen/CodeGenFunction.cpp
parent81cbbe3e17a4a9b2e0d227b591553d90eeab1400 (diff)
downloadllvm-191a6e9dfa1a54b616e12bde2efa849ad8e03f48.zip
llvm-191a6e9dfa1a54b616e12bde2efa849ad8e03f48.tar.gz
llvm-191a6e9dfa1a54b616e12bde2efa849ad8e03f48.tar.bz2
optimize icmp-ugt-ashr
This diff optimizes the sequence icmp-ugt(ashr,C_1) C_2. InstCombine already implements this optimization for sgt, and this patch adds support ugt. This patch adds the check for UGT. @craig.topper came up with the idea and proof: define i1 @src(i8 %x, i8 %y, i8 %c) { %cp1 = add i8 %c, 1 %i = shl i8 %cp1, %y %i.2 = ashr i8 %i, %y %cmp = icmp eq i8 %cp1, %i.2 ;Assume: C + 1 == (((C + 1) << y) >> y) call void @llvm.assume(i1 %cmp) ; uncomment for the sgt case %j = shl i8 %cp1, %y %j.2 = sub i8 %j, 1 %cmp2 = icmp ne i8 %j.2, 127 ;Assume (((c + 1 ) << y) - 1) != 127 call void @llvm.assume(i1 %cmp2) %s = ashr i8 %x, %y %r = icmp sgt i8 %s, %c ret i1 %r } define i1 @tgt(i8 %x, i8 %y, i8 %c) { %cp1 = add i8 %c, 1 %j = shl i8 %cp1, %y %j.2 = sub i8 %j, 1 %r = icmp sgt i8 %x, %j.2 ret i1 %r } declare void @llvm.assume(i1) This change is related to the optimizations in D117252. Differential Revision: https://reviews.llvm.org/D117365
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
0 files changed, 0 insertions, 0 deletions