All of lore.kernel.org
 help / color / mirror / Atom feed
* Potential incorrect simplification
@ 2017-03-28 12:40 Dibyendu Majumdar
  2017-03-28 13:34 ` Luc Van Oostenryck
  0 siblings, 1 reply; 59+ messages in thread
From: Dibyendu Majumdar @ 2017-03-28 12:40 UTC (permalink / raw)
  To: Linux-Sparse

I am getting a failure in following test when simplifications are enabled:

extern int printf(const char *, ...);

int main(void)
{
   struct{
     int twobit:2;
     int       :1;
     int threebit:3;
     unsigned int onebit:1;
   } s3;

   s3.onebit = 1;
   if(s3.onebit != 1){
      printf("Be especially careful with 1-bit fields! %d\n", (int) s3.onebit);
      return 1;
   }
   return 0;
}

The output (truncated) from linearizer without simplications is this:

main:
.L0:
        <entry-point>
        load.32     %r1 <- 0[s3]
        shl.32      %r2 <- $1, $6
        and.32      %r3 <- %r1, $-65
        or.32       %r4 <- %r3, %r2
        store.32    %r4 -> 0[s3]
        load.32     %r5 <- 0[s3]
        lsr.32      %r6 <- %r5, $6
        cast.32     %r7 <- (1) %r6
        setne.32    %r8 <- %r7, $1
        br          %r8, .L1, .L2

But if simplifications are on then we get:

main:
.L0:
        <entry-point>
        and.32      %r3 <- %r4, $-65
        or.32       %r4 <- %r3, $64
        lsr.32      %r6 <- %r4, $6
        cast.32     %r7 <- (1) %r6
        setne.32    %r8 <- %r7, $1
        br          %r8, .L1, .L3

Regards
Dibyendu

^ permalink raw reply	[flat|nested] 59+ messages in thread

end of thread, other threads:[~2017-08-10 13:25 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-28 12:40 Potential incorrect simplification Dibyendu Majumdar
2017-03-28 13:34 ` Luc Van Oostenryck
2017-03-28 13:58   ` Dibyendu Majumdar
2017-03-28 14:11     ` Luc Van Oostenryck
2017-03-28 14:19       ` Dibyendu Majumdar
2017-03-28 16:20         ` Linus Torvalds
2017-03-28 17:00           ` Luc Van Oostenryck
2017-03-28 18:02             ` Linus Torvalds
2017-03-28 20:27               ` Luc Van Oostenryck
2017-03-28 21:57                 ` Linus Torvalds
2017-03-28 22:28                   ` Luc Van Oostenryck
2017-03-28 22:22           ` Dibyendu Majumdar
2017-08-06 12:46           ` Christopher Li
2017-08-06 14:00             ` Luc Van Oostenryck
2017-08-06 14:24               ` Christopher Li
2017-08-06 14:54                 ` Christopher Li
2017-08-06 15:07                 ` Luc Van Oostenryck
2017-08-06 15:51                   ` Christopher Li
2017-08-06 16:51                     ` Luc Van Oostenryck
2017-08-06 18:35                       ` Christopher Li
2017-08-06 19:51                         ` Dibyendu Majumdar
2017-08-06 20:08                           ` Luc Van Oostenryck
2017-08-06 19:52                         ` Luc Van Oostenryck
2017-08-06 23:34                           ` Christopher Li
2017-08-07  0:31                             ` Luc Van Oostenryck
2017-08-07  0:38                               ` Christopher Li
2017-08-06 15:52                 ` Dibyendu Majumdar
2017-08-06 16:56                   ` Luc Van Oostenryck
2017-08-06 17:04                     ` Dibyendu Majumdar
2017-08-06 17:45                       ` Luc Van Oostenryck
2017-08-06 17:58                         ` Dibyendu Majumdar
2017-08-06 18:15                           ` Luc Van Oostenryck
2017-08-06 18:18                             ` Dibyendu Majumdar
2017-08-06 18:31                               ` Luc Van Oostenryck
2017-08-07 19:11                   ` [PATCH v2 0/8] fix loading of partially defined bitfield Luc Van Oostenryck
2017-08-07 19:11                     ` [PATCH v2 1/8] Remove single-store shortcut Luc Van Oostenryck
2017-08-07 21:42                       ` Linus Torvalds
2017-08-10  0:29                         ` Christopher Li
2017-08-10  0:41                           ` Luc Van Oostenryck
2017-08-10  0:53                             ` Christopher Li
2017-08-10 11:01                       ` Christopher Li
2017-08-10 12:26                         ` Luc Van Oostenryck
2017-08-10 13:25                           ` Christopher Li
2017-08-07 19:11                     ` [PATCH v2 2/8] new helper: def_opcode() Luc Van Oostenryck
2017-08-07 19:12                     ` [PATCH v2 3/8] reuse nbr_pseudo_users() Luc Van Oostenryck
2017-08-07 19:12                     ` [PATCH v2 4/8] change the masking when loading bitfields Luc Van Oostenryck
2017-08-07 19:12                     ` [PATCH v2 5/8] simplify ((A & M') | B ) & M when M' & M == 0 Luc Van Oostenryck
2017-08-07 19:12                     ` [PATCH v2 6/8] transform (A & M) >> S to (A >> S) & (M >> S) Luc Van Oostenryck
2017-08-08  0:22                       ` Christopher Li
2017-08-08  0:29                         ` Luc Van Oostenryck
2017-08-08  1:48                           ` Christopher Li
2017-08-08  1:00                         ` Linus Torvalds
2017-08-08  1:38                           ` Luc Van Oostenryck
2017-08-08  1:50                           ` Christopher Li
2017-08-07 19:12                     ` [PATCH v2 7/8] transform (A << S) >> S into A & (-1 " Luc Van Oostenryck
2017-08-07 21:54                       ` Linus Torvalds
2017-08-07 22:08                         ` Luc Van Oostenryck
2017-08-07 22:27                           ` Luc Van Oostenryck
2017-08-07 19:12                     ` [PATCH v2 8/8] fix: cast of OP_AND only valid if it's an OP_CAST Luc Van Oostenryck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.