[LLVMbugs] [Bug 9562] New: result of multiplication of two bit-fields not truncated

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Mar 25 15:18:30 PDT 2011


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

           Summary: result of multiplication of two bit-fields not
                    truncated
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: ahatanak at gmail.com
                CC: llvmbugs at cs.uiuc.edu


In the following example, result of a.u33 * a.u33 is not truncated to a 33-bit
value (see entry basic block in main):

# .c file (based on bitfld-3.c from torture test)
extern void exit (int);
extern void abort (void);

struct s {
  unsigned long long u33: 33;
  unsigned long long u40: 40;
  unsigned long long u41: 41;
};

struct s a = { 0x100000, 0x100000, 0x100000 };

int
main (void)
{
  if (a.u33 * a.u33 != 0 || a.u33 * a.u40 != 0 || a.u40 * a.u33 != 0
      || a.u40 * a.u40 != 0)
    abort ();
  exit (0);
}

# .ll file
# clang bitfld1.c -S -emit-llvm -O3 -o -
; ModuleID = 'bitfld1.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
2:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-pc-linux-gnu"

%0 = type { i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8 }

@a = global %0 { i8 0, i8 0, i8 16, i8 0, i8 0, i8 0, i8 32, i8 0, i8 0, i8 0,
i
8 0, i8 32, i8 0, i8 0, i8 0, i8 undef }, align 8

define i32 @main() noreturn nounwind {
entry:
  %0 = load i64* bitcast (%0* @a to i64*), align 8
  %bf.clear = and i64 %0, 8589934591
  %mul = mul i64 %bf.clear, %bf.clear
  %cmp = icmp eq i64 %mul, 0
  br i1 %cmp, label %lor.lhs.false, label %if.then

lor.lhs.false:                                    ; preds = %entry
  %1 = lshr i64 %0, 33
  %2 = load i64* bitcast (i8* getelementptr inbounds (%0* @a, i32 0, i32 8) to
i
64*), align 8

-- 
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