[LLVMdev] Stupid '-load-vn -licm' question (LLVM 1.6)

Eric Kidd emk.lists at gmail.com
Fri Mar 17 05:21:19 PST 2006


On Mar 17, 2006, at 7:54 AM, Eric Kidd wrote:
> Unfortunately, this generates really weird code on the LLVM 1.6  
> PowerPC backend:
>
> LBB_matches_1:  ; regex6
>         lbz r4, 0(r3)
> LBB_matches_2:  ; NodeBlock
>         rlwinm r5, r4, 0, 24, 31
>         cmplwi cr0, r5, 98
>         blt cr0, LBB_matches_4  ; LeafBlock
> LBB_matches_3:  ; LeafBlock1
>         rlwinm r4, r4, 0, 24, 31
>         cmpwi cr0, r4, 98
>         beq cr0, LBB_matches_8  ; ret_true
>         b LBB_matches_5 ; NewDefault
> LBB_matches_4:  ; LeafBlock
>         rlwinm r4, r4, 0, 24, 31
>         cmpwi cr0, r4, 97
>         beq cr0, LBB_matches_8  ; ret_true
> LBB_matches_5:  ; NewDefault
> LBB_matches_6:  ; loop_step
>
> I'm particularly confused by the rlwinm instructions that keep  
> turning up in PowerPC output, and the double test against 98. I  
> don't have a problem or anything; I'm just trying to figure out  
> what's going on. :-)

Ah! The backend is running -lowerswitch, which does a binary search  
of the case labels (even when there's only two of them).

If I run -lowerswitch manually, though, I *do* get some very nice  
results out of -cee. :-) It's automatically killing some backtrack  
nodes in my CFG, which is a big (and unexpected) win.

Overall, I'm extremely impressed with the LLVM optimizer framework-- 
even when it does something weird, it's easy to dive in and read the  
code. In the past, I've spent months working on compiler backends  
before feeling this comfortable.

Cheers,
Eric





More information about the llvm-dev mailing list