[LLVMbugs] [Bug 2638] New: Missing optimization (fold of ashr and sext)

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Tue Aug 5 10:41:10 PDT 2008


http://llvm.org/bugs/show_bug.cgi?id=2638

           Summary: Missing optimization (fold of ashr and sext)
           Product: new-bugs
           Version: unspecified
          Platform: Macintosh
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: daniel at zuster.org
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=1892)
 --> (http://llvm.org/bugs/attachment.cgi?id=1892)
Input .c file

LLVM misses some optimization of the attached test case:
--
ddunbar at ddunbar2:CodeGen$ llvm-gcc -c --emit-llvm -o - ~/rt/gaz.c | opt
-std-compile-opts | llvm-dis
; ModuleID = '<stdin>'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i386-apple-darwin9"

define i32 @foo(i32 %i) nounwind  {
entry:
        %tmp12 = trunc i32 %i to i8             ; <i8> [#uses=1]
        %tmp16 = shl i8 %tmp12, 6               ; <i8> [#uses=1]
        %sextr23 = ashr i8 %tmp16, 6            ; <i8> [#uses=1]
        %sextr2324 = sext i8 %sextr23 to i32            ; <i32> [#uses=1]
        ret i32 %sextr2324
}

For reference, here is the bytecode that comes from the IR generated by clang,
after optimization:
-- clang --
; ModuleID = '<stdin>'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i686-apple-darwin9.4.0"

define i32 @foo(i32 %i) nounwind  {
entry:
        %tmp9 = shl i32 %i, 30          ; <i32> [#uses=1]
        %tmp10 = ashr i32 %tmp9, 30             ; <i32> [#uses=1]
        ret i32 %tmp10
}

The difference comes from the way the bitfield load is generated....

No clue if this is worthwhile.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list